matlab双y轴作图_matlab中双坐标轴画图

x = 0:0.01:20;

y1 = 200*exp(-0.05*x).*sin(x);

y2 = 0.8*exp(-0.5*x).*sin(10*x);

y3 = sin(x);

[AX,H1,H2] = plotyy(x,[y1;100*y3],x,[y3;y2],'plot');

************************************

对原图双坐标的某一坐标加曲线:

x=linspace(0,2*pi,40);

[ax,h1,h2]=plotyy(x,sin(x)+cos(x),x,exp(x));

set(h1,'linestyle','-')

set(h2,'linestyle','-')

set(h1,'marker','o')

set(h2,'marker','+')

hold on

x=linspace(0,2*pi,40);

hh=line(x,cos(x));

set(hh,'linestyle','-')

set(hh,'marker','s')

hold on

hhf=line(x,sin(x));

set(hhf,'color','r')

set(hhf,'linestyle','-')

set(hhf,'marker','*')

legend([h1,h2,hh,hhf],'sin(x)+cos(x)','exp(x)','cos(x)','sin(x)',0);

********************************

my codes:

clear all

clc;

%**************

I = 0:0.005:4;

V1 = zeros(1,length(I));

Irr = 1000;

Temp = 25;

for i = 1:length(I)

V1(i)

= PV_model_current_test_noDiode(I(i),Irr,Temp);

end

P1=V1.*I;

%**************

I = 0:0.005:4;

V = zeros(1,length(I));

Irr = 300;

Temp = 25;

for i = 1:length(I)

V2(i)

= PV_model_current_test_noDiode(I(i),Irr,Temp);

end

P2=V2.*I;

%**************

figure(1);

[AX,H1,H2] = plotyy(V1,I,V1,P1);

set(H1,'LineStyle','-','LineWidth',4);

set(H1,'color','b');

set(H2,'LineStyle','-.','LineWidth',4);

set(H2,'color','b');

set(AX(1),'xlim',[0 45],'ylim',[0

5],'FontSize',40,'LineWidth',6,'Xcolor','k','Ycolor','k','FontName','Times

New Roman');

set(AX(2),'xlim',[0 45],'ylim',[0

65],'FontSize',40,'LineWidth',6,'Xcolor','k','Ycolor','k','FontName','Times

New Roman');

set(get(AX(1),'Ylabel'),'string','I

(A)','FontSize',40,'FontName','Times New Roman');

set(get(AX(2),'Ylabel'),'string','P

(W)','FontSize',40,'FontName','Times New Roman');

xlabel('V (V)');

set(AX(1),'ytick',[0:1:5]);

set(AX(2),'ytick',[0:13:65]);

hold on;

hhf1=plot(AX(1),V2,I);

set(hhf1,'color','k')

set(hhf1,'linestyle','-.','LineWidth',6)

hold(AX(2));

hhf2=plot(AX(2),V2,P2);

set(hhf2,'color','k')

set(hhf2,'linestyle',':','LineWidth',6)

hold on;

hhf3=plot(AX(1),V2+V1,I);

set(hhf3,'color','r')

set(hhf3,'linestyle','--','LineWidth',6)

hold on;

hhf4=plot(AX(2),V2+V1,P2+P1);

set(hhf4,'color','r')

set(hhf4,'linestyle',':','LineWidth',6)

grid off

Note: 可以先对AX1

和AX2分别画一条曲线,然后再用hold on; plot来对两坐标添加更多的曲线。

你可能感兴趣的:(matlab双y轴作图)