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

    %% Specify Axes for Line Plot
% Create a figure with two subplots and return the handle to each subplot
% axes, |ax1| and |ax1|.

% Copyright 2015 The MathWorks, Inc.


figure % new figure
ax1 = subplot(2,1,1); % top subplot
ax2 = subplot(2,1,2); % bottom subplot

%% 
% Create a 2-D line plot in each axes by referring to the axes
% handles. Add a title and _y_-axis label to each axes by passing the axes
% handles to the |title| and |ylabel| functions.

x = linspace(0,3);
y1 = sin(5*x);
y2 = sin(15*x);

plot(ax1,x,y1)
title(ax1,'Top Subplot')
ylabel(ax1,'sin(5x)')

plot(ax2,x,y2)
title(ax2,'Bottom Subplot')
ylabel(ax2,'sin(15x)')