Chapter 26
2D Graphics
26.1 The
plot
Function
The basic function for producing 2D graphs is the MATLAB '
plot
' function.
It
is generally called with two identically sized row (or column) vectors, one for the set of
abscissa values and the second for the ordinate axis.
The plotted points are ordered pairs
of values, one from the first vector and one from the second vector.
For example, to plot
the points
1
1
2
2
( ,
), ( ,
), .
...., (
,
)
n
n
x y
x y
x y
the arrays
x=
[
]
1
2
,
, .....
,
n
x x
x
and
y=
[
]
1
2
,
, .....
,
n
y y
y
are created and then passed to the plot function for graphing.
Example 26.1.1
x=[0 2 5 8 10]; % Create x vector
y=[0 4 3 3 6]; % Create y vector
plot(x,y) % Plot (0,0), (2,4), (5,3), (8,3), (10,6)
When the '
plot'
command is issued within an mFile or from the Command
window, MATLAB opens a new Figure window, draws a set of axes automatically scaled
to fit the data, plots the points in the order in which they appear in the two vectors, and
then connects all the points by straight lines.
Numerical scales appear on both axes as do
tick marks.
The '
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 klee
 Array

Click to edit the document details