Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

No line while plotting using "for" command

3 visualizaciones (últimos 30 días)
Michalis Nearchou
Michalis Nearchou el 1 de Nov. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 comentarios
darova
darova el 1 de Nov. de 2019
Use
plot(w,Clmax2D,'.b');
Adam
Adam el 1 de Nov. de 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.

Respuestas (1)

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

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by