Toggles the hold state on the currently active plot. The general syntax for its use is
grid(state)
where state is either
hold('on')
to turn hold on, or
hold('off')
to turn hold off.
The hold function allows one to construct a plot sequence
incrementally, instead of issuing all of the plots simultaneously
using the plot command.
Here is an example of using both the hold command and the
multiple-argument plot command to construct a plot composed
of three sets of data. The first is a plot of a modulated Gaussian.
--> x = linspace(-5,5,500); --> t = exp(-x.^2); --> y = t.*cos(2*pi*x*3); --> plot(x,y);
We now turn the hold state to 'on', and add another plot
sequence, this time composed of the top and bottom envelopes of
the modulated Gaussian. We add the two envelopes simultaneously
using a single plot command. The fact that hold is
'on' means that these two envelopes are added to (instead of
replace) the current contents of the plot.
--> plot(x,y); --> hold on --> plot(x,t,'g-',x,-t,'b-')