not getting a plot why? plz help
1 次查看(过去 30 天)
显示 更早的评论
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
回答(1 个)
Steven Lord
2021-3-8
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)
disp(P_req)
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 个评论
Steven Lord
2021-3-9
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!