- MatLab function plot plots given ordered pairs
(x(1),y(1)), (x(2),y(2)),..., where x(i) and y(i) are stored in
vectors x and y. For example, copy and paste the
following 4 commands in MatLab to see how plot works.
x=[1;2;3;4];
y=[-1;2;-3;4];
plot(x,y,'--')
'--' in plot is for the line-type. Other line types and
point types are:
line-type: -, --, :, -.
point-type: ., +, *, o, x
Type help plot to learn more about plot.
- MatLab function subplot provides a location
for a graph on a multigraphs screen.
For example, subplot(3,2,4) means that the plotted graph is
the 4th graph on a screen which has
6 graphs (in 3 rows and 2 columns). Try the following commands
to see how subplot works.
x=[1;2;3;4];
y=[-1;2;-3;4];
subplot(3,2,4),plot(x,y,'--')
Type help subplot to learn more about subplot.
- MatLab function axis provides limits of x-axis
and y-axis. For example,
subplot(3,2,4),axis([-5 5 -6 6])
subplot(3,2,4),axis square
x is in [-5 5] and y is in [-6 6] and then the graph window becomes
a square window.
Type help axis to learn more about axis.
- MatLab function title displays a given title
in text. For example,
title('It is a test.')
the title will be above the graph window.
- MatLab function text allows us to add text to
the graph. For example,
text(1,2,'It is a test.')
the text will be added at the location (1,2).
- MatLab function clg (for MatLab
version 4) and clf (for MatLab
version 5) cleans the screen.
Type help clg or help clf
to learn more about these two comments.