%双横坐标绘制
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;
hl1 = line(x1,y1,'Color','r');
ax1 = gca;
set(ax1,'XColor','r','YColor','r')
ax2 =
axes('Position',get(ax1,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k'
,'YColor','k');
hl2 =
line(x2,y2,'Color','k','Parent',ax2);
双横坐标绘制
%双纵坐标轴
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');
set(get(AX(1),'Ylabel'),'String','SlowDecay')
set(get(AX(2),'Ylabel'),'String','FastDecay')
xlabel('Time (\musec)')
title('Multiple Decay Rates')
双纵坐标轴
function [ax,hlines] =
plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%PLOTYYY - Extends plotyyto include a third
y-axis
%
%Syntax: [ax