The basic syntax to get a plot in matlab is


(The x values always come before the y values, x1 and y1 represent variables that your data is stored in.) If you type a second plot command later, it will clear your first plot. If you type "hold on" it will hold the current plot so you can add plots on top of one another (until you reset it by typing "hold off".)

You can plot multiple values with plot(x1,y1,x2,y2) and you can specify the color and linetype of a plot as something like plot(x1,y1,'w*') to get white *'s for each data point.

To split your plot into a bunch of smaller plots, you can use the subplot command to split it up into rows and columns.


will split the plot window into r rows and c columns of plots and set the current plot to plot number n of those rows and columns. For example, subplot(2,1,1) splits the plot window into two rows in a single column and prepares to plot in the top plot. Then your plot command will plot in the top plot. Then you could switch to the bottom plot with subplot(2,1,2) and use another plot command to plot in the bottom plot.

You can add titles, labels, and legends to plots.

title('This is a Title')
xlabel('My X axis')
ylabel('My Y axis')
legend('First Thing Plotted','Second Thing Plotted')
legend creates a legend box (movable with the mouse) that automatically uses the right symbols and colors and sticks the descriptions in the legend command after them.