Info

此问题已关闭。 请重新打开它进行编辑或回答。

No line while plotting using "for" command

1 次查看(过去 30 天)
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 个评论
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.

产品

Community Treasure Hunt

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

Start Hunting!

Translated by