Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

No line while plotting using "for" command

1 Ansicht (letzte 30 Tage)
Michalis Nearchou
Michalis Nearchou am 1 Nov. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
darova
darova am 1 Nov. 2019
Use
plot(w,Clmax2D,'.b');
Adam
Adam am 1 Nov. 2019
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.

Antworten (1)

Subhadeep Koley
Subhadeep Koley am 4 Nov. 2019
Bearbeitet: Subhadeep Koley am 4 Nov. 2019
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 Kommentare
Stephen23
Stephen23 am 4 Nov. 2019
Note that this is quite inefficient.
Much more efficient would be to plot matrices/arrays.
Subhadeep Koley
Subhadeep Koley am 4 Nov. 2019
Bearbeitet: Subhadeep Koley am 4 Nov. 2019
Stephen Cobeldick Yes I agree. This is very inefficient.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by