Why my plot is blank?

1 Ansicht (letzte 30 Tage)
Nirmith Kumar Mishra
Nirmith Kumar Mishra am 25 Sep. 2021
Beantwortet: Image Analyst am 25 Sep. 2021
clc
clear all
close all
w0=73000;
S=950;
AR=5.92;
C_D0=0.015;
K=0.08;
rho=8.9068*10^-4;
for V=300:100:1300
CL=(2*w0)/(rho*V^2*S);
CD=C_D0+K*CL^2;
Tr=0.5*rho*V^2*S*CD;
disp([' At free stream velcoity ', num2str(V), ' m/s, CL is ', num2str(CL), ' , CD is ', num2str(CD) ' , Tr is ', num2str(Tr)]);
end
plot(V,Tr)

Akzeptierte Antwort

Image Analyst
Image Analyst am 25 Sep. 2021
You didn't index V or Tr. Try this:
clc
clear all
close all
w0=73000;
S=950;
AR=5.92;
C_D0=0.015;
K=0.08;
rho=8.9068*10^-4;
allV=300:100:1300
Tr = zeros(1, length(allV));
for k = 1 : length(allV)
V = allV(k);
CL=(2*w0)/(rho*V^2*S);
CD=C_D0+K*CL^2;
Tr(k)=0.5*rho*V^2*S*CD;
fprintf(' At free stream velocity %d m/s, CL is %f, CD is %f, Tr is %f\n', ...
V, CL, CD, Tr(k));
end
plot(allV, Tr, 'b.-', 'LineWidth', 2, 'MarkerSize', 30)
grid on;
xlabel('V', 'FontSize', 15);
ylabel('Tr', 'FontSize', 15);

Weitere Antworten (1)

Cris LaPierre
Cris LaPierre am 25 Sep. 2021
The most likely reason is that V and Tr are a single number. By default, MATLAB does not plot using markers, so if there is only a single point, you won't see it.
See this answer for how to create a vector using a for loop.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2011a

Community Treasure Hunt

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

Start Hunting!

Translated by