双纵坐标图:plotyy(x1, y1, x2, y2, 'plotf1', 'plotf2')
x1,y1 表示第一个函数的自变量和因变量:x2,y2 表示第二个函数的自变量和因变量。通常 y1 和 y2 不在一个量级上时使用 plotf1 和 plotf2 是说明用什么画图函数画函数 1 和函数 2。
示例:
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');

双纵坐标图:yyaxis left 或 yyaxis right
x = linspace(0,10);
y= sin(3*x);
yyaxis left
plot(x,y);
figure(2);
z=sin(3*x).*exp(0.5*x);
yyaxis right
plot(x,z);
ylim([- 150 150])%y轴范围


网友评论