在情节中绘制相同的数字

时间:2016-05-09 23:41:50

标签: matlab plot matlab-figure figure

早上好, 我试图在Matlab中用相同的代码绘制这个图。但它根本不起作用。我根本无法获得相同的数字,而是使用plotyy。 我需要它与plotyy的原因是让读者通过绘制相同的函数但乘以常数来理解左手数字的重要性。右侧将被称为增益,因此读者将至少知道某些功率获得了多少增益。 HEre是代码:

[![r=1:0.001:3;
R=50;
kappa=0.5;
L1=1000;
c1=R/(8*kappa*L1);
Frmin=(r+r.^-1).*(r-1)./(r+1);
Frmax=(r+r.^-1).*(atan(r)-atan(1./r));
P1min=c1.*Frmin;% the 1st function for the left hand side of plotyy
P1max=c1.*Frmax;% the 2nd function for the left hand side of plotyy
YYmin=P1min*20; % the 1st function for the right hand side of plotyy
YYmasx=P1max*20;% the 2nd function for the right hand side of plotyy
figure;
ha1 = area(\[1 3\], \[0 M.*c1\]);
hold on
plot(r,P1min,'r','Linewidth',8)
fill(\[r fliplr(r)\],\[P1min,fliplr(P1max)\],'y')
plot(r,P1max,'k','Linewidth',5);
hold off
legend('\Delta >0','\Delta=0', '\Delta<0','Pmax')
%,'900','800','700','600','500')
xlabel('r')
ylabel('P_p (W)')
title('P_p vs r for L= 1000 m')][1]][1]

所以我希望我能得到一些帮助。我可以告诉你我的一些尝试错误尝试,但后来我不清楚我的目标是再次用相同的颜色绘制相同的数字,但使用plotyy。谢谢,抱歉这条长信息。

1 个答案:

答案 0 :(得分:0)

这是您要找的吗?

编辑你的代码(这是有效的):

r=1:0.001:3;
R=50;
kappa=0.5;
L1=1000;
c1=R/(8*kappa*L1);
Frmin=(r+r.^-1).*(r-1)./(r+1);
Frmax=(r+r.^-1).*(atan(r)-atan(1./r));
P1min=c1.*Frmin;% the 1st function for the left hand side of plotyy
P1max=c1.*Frmax;% the 2nd function for the left hand side of plotyy
YYmin=P1min*20; % the 1st function for the right hand side of plotyy
YYmasx=P1max*20;% the 2nd function for the right hand side of plotyy
figure;
M = 1;
ha1 = area([1 3], [0 M.*c1]);
hold on
plot(r,P1min,'r','Linewidth',8)
fill([r fliplr(r)],[P1min,fliplr(P1max)],'y')
plot(r,P1max,'k','Linewidth',5);

你的因素和情节

myFactor1 = 5;
[ax,~,~] = plotyy(r,P1min,r,myFactor1*P1min);

将轴颜色设置为黑色并控制字体

set(ax,{'ycolor'},{'k';'k'},{'FontSize'},{8;15})

其余代码,已编辑且正在运行

legend('\Delta >0','\Delta=0', '\Delta<0','Pmax')
xlabel('r')
ylabel('P_p (W)')
title('P_p vs r for L= 1000 m')