not getting a plot why? plz help

1 view (last 30 days)
Sourav singh
Sourav singh on 8 Mar 2021
Commented: Sourav singh on 10 Mar 2021
sigma=0.047193;
V_tip=180;
W=180;
Cd_avg=0.01;
R=2.235;
k=1.1;
A=pi*R.^2;
P_e= 61147.4;
h=0:100:1200;
for i = 1:numel(h)
rho = 1.225*((288-0.0065*h(i))/288)^4.2561;
P_req(i)=k*((W)^(3/2))./sqrt(2.*rho.*A)+(Cd_avg*rho*sigma*A.*(V_tip).^3)./(8) +747.643-(0.03*P_e);
V_c(i)=(P_e-P_req(i))./W;
end
hold on
plot(P_e,h,'r--',P_req,h,'r-');
xlabel("power");
ylabel("h");
hold off

Answers (1)

Steven Lord
Steven Lord on 8 Mar 2021
sigma=0.047193;
V_tip=180;
W=180;
Cd_avg=0.01;
R=2.235;
k=1.1;
A=pi*R.^2;
P_e= 61147.4;
h=0:100:1200;
for i = 1:numel(h)
rho = 1.225*((288-0.0065*h(i))/288)^4.2561;
P_req(i)=k*((W)^(3/2))./sqrt(2.*rho.*A)+(Cd_avg*rho*sigma*A.*(V_tip).^3)./(8) +747.643-(0.03*P_e);
V_c(i)=(P_e-P_req(i))./W;
end
disp(P_e)
6.1147e+04
disp(P_req)
1.0e+03 * 5.9554 5.8941 5.8334 5.7731 5.7133 5.6540 5.5951 5.5367 5.4788 5.4213 5.3643 5.3078 5.2517
plot(P_e,h,'r--',P_req,h,'r-');
The fact that you're plotting a scalar x versus a vector y seems a bit odd, as does the fact that you're plotting using P_req as your X data and h as your Y data. Since P_req uses rho which is a function of h(i) I would probably plot(h, P_req). And if you want a vertical line at x = P_e use the xline function.
I'm guessing you're not seeing any lines on your plot. If you'd plotted into that axes and turned hold on prior to executing that plotting command, what are the limits on that axes? Note that the values of P_req are on the order of 5000-6000. If you'd held the axes with limits (say) 1-10 then the line would be plotted waaaaaaay off the right side of the visible area.
  5 Comments
Steven Lord
Steven Lord on 9 Mar 2021
As I said, see the xlim function or (if you want to control the X and Y axis limits at the same time) the axis function.
You need to choose and/or calculate the limits that the X axis should have to show all your data. The min, max, and/or bounds functions may be useful to you in that task.
Sourav singh
Sourav singh on 10 Mar 2021
thank u sir for helping me out

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!