Member-only story

The "hold" command

Raheelanjum
3 min readDec 11, 2024

--

Sometimes you will want to plot multiple graphs on the XY axis (on the same figure). In Matlab, when you use the plot function more than once, each time you call it, the previous figure is "erased.".

To make a previous figure remain on the plot, we use the "hold on;" command. When we want to resume clearing the figure for each new plot, we use the "hold off;" command.

Try the following code.

You should have only seen one graph, the cubed graph (which was the second plot above). Now try this code, using the "hold on;" command.

The "subplot" command

Sometimes you will want to place multiple plots side by side on a single figure. You can achieve this by using the Matlab subplot function.

For many more details on this function (as well as the commands and functions mentioned above), you can always use the help command at the Matlab prompt.

--

--

Raheelanjum
Raheelanjum

Written by Raheelanjum

Highly skilled and experienced content writer dedicated to crafting compelling, informative content that resonates with diverse audiences. Expertise spans blog

Responses (11)