www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/PlotDataUsingTwoYAxesExample.m

    %% Plot Data Using Two y-Axes
% Create axes with a _y_-axis on both the left and right sides. Plot a set
% of data against the left _y_-axis. Then, use |yyaxis right| to activate
% the right side so that subsequent graphics functions target it. Plot a
% second set of data against the right _y_-axis and set the limits for the
% right _y_-axis.

x = linspace(0,10);
y = sin(3*x);
yyaxis left
plot(x,y)

z = sin(3*x).*exp(0.5*x);
yyaxis right
plot(x,z)
ylim([-150 150])