When working with plots in MATLAB, the "hold on" command allows you to add multiple graphical objects (such as lines, points, or shapes) to the same plot. By default, any new plot command overwrites the existing plot, but with "hold on" enabled, subsequent commands will add to the existing plot.
Here's an example of how to use hold on:
main.m342 chars16 lines
In this example, the "hold on" command is used to add a second function (cosine) to the same plot as the first function (sine). Without "hold on", the second plot would overwrite the first plot, and only the cosine function would be visible. Instead, both functions are displayed on the same plot, and a legend is added to indicate which is which.
gistlibby LogSnag