在 plotyy 中绘制相同的图形
Plot thie same figure in plotyy
早上好,
我试图在 Matlab 中用相同的代码绘制这个图。但是它根本不起作用。我根本无法得到相同的数字,而是使用 plotyy。
我需要 plotyy 的原因是 reader 通过绘制相同的函数但乘以常数来理解左侧数字的重要性。右侧将称为增益,因此 reader 将至少知道特定功率可获得多少增益。
这是代码:
[![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。谢谢你,抱歉这么长的留言。
这是您要找的吗?
编辑您的代码(有效):
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')
早上好, 我试图在 Matlab 中用相同的代码绘制这个图。但是它根本不起作用。我根本无法得到相同的数字,而是使用 plotyy。 我需要 plotyy 的原因是 reader 通过绘制相同的函数但乘以常数来理解左侧数字的重要性。右侧将称为增益,因此 reader 将至少知道特定功率可获得多少增益。 这是代码:
[![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。谢谢你,抱歉这么长的留言。
这是您要找的吗?
编辑您的代码(有效):
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')