%% Specify Hold State for Specific Axes
% Create a figure with two subplots and add a line plot to each subplot. 

% Copyright 2015 The MathWorks, Inc.


ax1 = subplot(2,1,1);
x = linspace(0,2*pi);
y1 = sin(x);
plot(x,y1)

ax2 = subplot(2,1,2);
y2 = cos(x);
plot(x,y2)

%%
% Add a second line plot to the upper subplot.

hold(ax1,'on')
y3 = sin(2*x);
plot(ax1,x,y3)

%%
% Reset the hold state to off for the upper subplot so that
% new plots replace the existing plots, which is the default behavior. 

hold(ax1,'off')
y4 = sin(4*x);
plot(ax1,x,y4)