Practical 2: Variables, Script M-files and Graphing

Graph Commands

 

Table of the most useful commands for plotting graphs
hold on Allows plotting several graphs on the same figure. All commands after this one apply to a current figure, until the hold off command is used.
plot([x1 x2], [y1 y2]) plots the straight line between points (x_{1}, y_{1}) and (x_{2}, y_{2})
axis([minX maxX minY maxY]) specifies axis limits
legend(‘y1=equation1’, ‘y2=equation2’) sets the labels for the legend (must be after plot command)
xlabel(‘label for x axis’) sets the label for the x - axis
ylabel(‘label for y axis’) sets the label for the y - axis
title(‘graph title’) sets the label for the title
hold off Following commands no longer apply to the current figure.