02.03.2016 Views

MATLAB by rudra pratap

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.3 3-D Plots<br />

201<br />

6.3.4 Vector field and volumetric plots<br />

One of the most crucial needs of visualization in scientific computation is for data<br />

that is essentially volumetric, i.e., defined over a 3-D space. For example, we may<br />

have temperature or pressure defined over each (x, y, z) triple in a bounded 3-D<br />

space. How do we display this data graphically? If we have a function z = f ( x, y)<br />

defined over a finite region of the xy-plane, we can display z or f as a 3-D surface.<br />

But we have f(x, y, z)! So, we need a 4-D hypersurface. That is the basic problem.<br />

We display volumetric data <strong>by</strong> slicing it along several planes in 3-D and plotting<br />

the data on those planes, either with graded color maps or with contours. Such<br />

displays are still an area of active research. However, we can do fairly well with the<br />

tools currently available. One of the most common applications is in the area of<br />

3-D vector fields. A vector field defines a vector quantity as a function of the space<br />

variables ( x, y, z) . Fortunately, in this case we can display the data (the vector) with<br />

an arrow drawn at each (x, y, z) triple, with the magnitude of the vector represented<br />

<strong>by</strong> the length of the arrow, and the direction represented <strong>by</strong> the orientation of the<br />

arrow. This concept is used extensively in dynamical systems in various ways.<br />

<strong>MATLAB</strong> provides extensive tools for visualizing vector fields and volumetric<br />

data. Unfortunately, these tools are beyond the scope of this book_ Therefore, we<br />

merely mention the tools here and give examples of only the "most likely to be<br />

used" tools.<br />

Plotting vector fields<br />

The plotting functions available in <strong>MATLAB</strong> for vector field visualization include<br />

quiver, quiver3, stream2, stream3, streamline, streamtube, streamribbon,<br />

streamslice, streamparticles, coneplot, divergence, curl, etc.<br />

If u(x, y) and v(x, y) are given as vector components in x- and y-directions,<br />

respectively, then the vector field can be easily drawn with quiver (qui ver3 in<br />

3-D). An example of quiver appears on page 188 in the table of 2-D plots. The<br />

stream functions are an extension of the same concept; they draw streamlines or<br />

trajectories from user-specified points in the specified vector field. This suite of<br />

functions has been a welcome addition in <strong>MATLAB</strong> (version 6 onward).<br />

The function streamline is useful for drawing solution trajectories in 2-D and<br />

3-D vector fields defined <strong>by</strong> ODEs. You need not solve the ODEs!<br />

Example: Let<br />

x y + x - x(x 2 + y 2 ) and<br />

Y<br />

-x + Y - y(x2 + y2).<br />

These two ODEs define a vector field (u = x and v = y). Let u::; use streamline to<br />

draw a few solution trajectories starting from various points in the xy-plane (initial<br />

conditions in the phase plane). The general syntax of streamline is<br />

streamline (x,y,z, u,v,w, xO ,yO,zO)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!