To plot multiple data on one plot in Matlab, you can follow these steps:
plot()
function.main.m10 chars2 lines
hold on
command to hold the first plot so that subsequent plots can be overlayed on top of it.main.m8 chars2 lines
plot()
function, just like the first one.main.m10 chars2 lines
plot()
function and ensuring that hold on
is still active.main.m10 chars2 lines
legend()
function, with the input arguments being a cell array of strings that match the order of the plotted data sets.main.m22 chars2 lines
Here is the full example code:
main.m101 chars12 lines
This will result in a plot with all the data sets overlaid on top of each other, with a legend identifying which line corresponds to which data set.
gistlibby LogSnag