This code plot nothing and i don't understand why ?!

i=1;
j=1;
x=y1(:,2);
u=y1(:,4);
figure
while (i<= size(x)& j<=size(u))
vv= x(i)*sin(u(j));
xx= x(i)*(1-cos(u(j)));
hold on
plot(vv,xx,'r');
i= i+1;
j= j+1;
end

回答 (2 件)

the cyclist
the cyclist 2014 年 11 月 6 日

1 投票

My guess is that size(x) is going to be something like
[7 1]
so i is not less than that. I think maybe you want length(x) or numel(x) instead of size(x).

1 件のコメント

Omar
Omar 2014 年 11 月 6 日
thanks alot
James Tursa
James Tursa 2014 年 11 月 6 日
編集済み: James Tursa 2014 年 11 月 6 日

0 投票

size(x) and size(u) are vectors, so i<= size(x)& j<=size(u) is a vector result, which is not what you likely intended. Try using numel instead so that it is a scalar expression. E.g.,
while (i<= numel(x) && j<=numel(u))
Also, you might want to specify a dot in the plot command:
plot(vv,xx,'r.');

1 件のコメント

Omar
Omar 2014 年 11 月 6 日
thanks alot

この質問は閉じられています。

質問済み:

2014 年 11 月 6 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by