Graphics Reference
In-Depth Information
3.3 Graphics in Parametric 3-D Coordinates
Let's see here how MATLAB draws curves in parametric coordinates in space, also known as warped curves in
parametric coordinates . The fundamental problem is to get graphs of tridimensional functions in which
the variable x, y and z depend, in turn, on a parameter t.
The command that can be used is plot3 and all its variants, by suitably defining intervals of variation of the
parameter, not by the independent variable as it was until now.
This type of graphic is very useful in certain matters, such as, for example, differential geometry.
Here is an example:
>> t = -4*pi:0.01:4*pi;
>> x = cos(t) .^ 2;
>> y = sin(t) .* cos (t);
>> z = sin(t);
>> plot3(x, y, z)
This generates the graph in Figure 3-3 .
Figure 3-3.
3.4 Surfaces, Meshes and Contours
So far we have seen the 3D graphics based on a line that moves in three dimensions to form a warped curve.
Now let's see how 3D graphics corresponding to surfaces and their different variants are made available.
3.5 Surfaces in Explicit Coordinates
Surface graphics allow for dense representations of tridimensional figures, and in particular of functions of two
variables. The first step in representing a function of two variables z = f(x,y) using a surface chart, is to use the
command meshgrid , which basically defines the array of points (X, Y) on which the function of two variables is
evaluated for its graphical representation. Its syntax is as follows:
[X, Y] = meshgrid(x,y)
Parameters x and y are vectors that are replicated into to matrices X and Y. Each matrix will have the same
number of rows as the length of x, and the same number of columns as the length of y. The increments of values in
each of the vectors determine the “spacing” of the resulting grid. For example, x of [-10:0.1:10] and y of [-2:0.1:2] will
 
Search WWH ::




Custom Search