Overview | |||||||||||||||||||||||||||||
To get an overview of available graphics functions in Matlab, look at the help pages for the following topics:
This article illustrates the use of the easy to use
graphics commands listed under the topic
This brief document mainly consists of examples of Matlab code. It is suggested that you have Matlab running while reading so that you can verify the examples. Each of the examples includes an image of the expected result. Just click on the View Result tag to the right of the Matlab code. |
Plotting curves:
ezplot ,
ezplot3 |
|||||||||||||||
We begin with an example of 2-D graphics using
For more complicated functions, first define the function through
an m-file, then pass the name of the function to the
plotting routine. Note that such a function must be written to
operate on a vector of input values (in Matlab lingo, the function
must be vectorized). For example, consider the
following piecewise function defined in the file
Now plot y = f(x) for several choices of the parameter a, overlaying the plots on a single axis.
Plot the parametric curve, x(t) = t + 2sin(2t), y(t) = t + 2cos(5t).
In xyz-space, use
Note : When using the The exact sequence for editing graphics windows is not the same across all operating systems and versions of Matlab. Some of these editing features first appeared in version 5 but underwent significant changes in version 6. Moreover, the Linux version appears to be different than the Windows version. |
Contour plots, level curves:
ezcontour ,
ezplot |
|||||||
The function
To plot specific level curves, it is more effective to use
|
Surfaces as graphs:
ezmesh ,
ezsurf |
||||||||||||||||
To introduce three-dimensional viewing of surfaces, we first consider examples of surfaces that can be plotted as graphs, z = f(x,y). The
The function The The viewing angle for 3-D graphics can be changed by dragging the
mouse inside the figure window if
The
The choice of colors for surface plots is determined by the current
colormap. To see a list of available colormaps and a
one-line description of each, run The
The following example graphs the upper half of the sphere x2 + y2 + z2 = 9 and overlays the tangent plane at (x, y, z) = (0.5, 0.5, 2.915).
|
Parametric surfaces:
ezmesh ,
ezsurf |
||||||||||||||||
[See Section 10.5 of Stewart's text for an introduction to
parametric surfaces.]
| In the previous example for the upper half-sphere, note the ragged edge where the sphere meets the xy-plane. Here is an example of a surface that is best represented in parametric form, The functions
Surfaces of revolution are best represented in parametric form. In the following example, the curve x = sin2(πx) is rotated about the z-axis on the interval -1 ≤ z ≤ 1.
|