Info

この質問は閉じられています。 編集または回答するには再度開いてください。

No line while plotting using "for" command

1 回表示 (過去 30 日間)
Michalis Nearchou
Michalis Nearchou 2019 年 11 月 1 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I was trying to make a plot, but there is no line after I run it. Can anyone help with that?
mu = 0.0000181206; rho = 1.225;
vc= 15; vstall=5; vmax=1;
g=9.81;span= 1;
for w=0.5:1.5:21
for c=0.16:0.33:18
L=w*g;
S = c*span;
AR=span/c;
Cl3D=(Lift)./(0.5*rho*vc.^2*S);
Cl2D=(Cl3D)./(0.95*0.9);
Clmax3D= (Lift)./(0.5*rho.*vstall.^2*S);
Clmax2D= (Clmax3D)./(0.95.*0.9);
re=(rho*c*vc)./mu;
plot(w,Clmax2D);
end
end
  2 件のコメント
darova
darova 2019 年 11 月 1 日
Use
plot(w,Clmax2D,'.b');
Adam
Adam 2019 年 11 月 1 日
You are plotting single points at a time, and without a
hold on
instruction, so each will replace the last and you will end up with just a single point.
Nevertheless, plotting like this is very inefficient. You should just store the results from your loop in arrays and then do a single plot instruction after the loop. Even using 'hold on' would not join your dots and would give you a huge number of individual graphics objects instead of just one.

回答 (1 件)

Subhadeep Koley
Subhadeep Koley 2019 年 11 月 4 日
編集済み: Subhadeep Koley 2019 年 11 月 4 日
Hi, using hold on you can plot all the points in the figure.
mu = 0.0000181206; rho = 1.225;
vc= 15; vstall=5; vmax=1;
g=9.81;span= 1;
Lift = ones(1,100); % I have used a random data for the variable Lift
for w=0.5:1.5:21
for c=0.16:0.33:18
L=w*g;
S = c*span;
AR=span/c;
Cl3D=(Lift)./(0.5*rho*vc.^2*S);
Cl2D=(Cl3D)./(0.95*0.9);
Clmax3D= (Lift)./(0.5*rho.*vstall.^2*S);
Clmax2D= (Clmax3D)./(0.95.*0.9);
re=(rho*c*vc)./mu;
plot(w,Clmax2D,'*b');
hold all;
end
end
hold off;
  2 件のコメント
Stephen23
Stephen23 2019 年 11 月 4 日
Note that this is quite inefficient.
Much more efficient would be to plot matrices/arrays.
Subhadeep Koley
Subhadeep Koley 2019 年 11 月 4 日
編集済み: Subhadeep Koley 2019 年 11 月 4 日
Stephen Cobeldick Yes I agree. This is very inefficient.

製品

Community Treasure Hunt

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

Start Hunting!

Translated by