not getting a plot why? plz help
显示 更早的评论
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 个)
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 个评论
Responding to the questions Sourav singh posted as an answer (which should have been a comment):
yes i want vertical line ar x=P_e how can is use xline functin (xline=P_e)?
plot(1:10, 1:10);
xline(5, 'r')
See the documentation page for the xline function for more information about the options with which you can call that function.
sir ,you are saying that to b in a single plot the values of P_e and P_req should b in same range ( like b/w5000-6000)
If you wanted to show the net worths of Bill Gates and a stereotypical college student, the axes on which you plot that data will need to span from a number very close to zero (for the college student) to a very large number (for Bill Gates.)
Or to put it another way, if I show you a map of the United States and ask you to show me where London, England is you're going to point to somewhere not on the map. If I used a map of the world, though, you'd point to a spot on the map. London doesn't need to change its location, you just need a wider view on the world.
what should i do know ? i want i h in y axis and power on x axis( P_req, as walll as P_e)
So call plot to plot your vector of data P_req and use xline to plot your scalar data P_e.
can we change the limit of X axis , is this possibe?
See the xlim function or (if you want to control the X and Y axis limits at the same time) the axis function.
Sourav singh
2021-3-9
编辑:Stephen23
2021-3-9
Sourav singh
2021-3-9
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.
Sourav singh
2021-3-10
类别
在 帮助中心 和 File Exchange 中查找有关 Two y-axis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

