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.

• Graphics<br />

<strong>MATLAB</strong> includes good tooh:; for visualization. Basic 2-D plots, fancy 3-D graphics<br />

with lighting and colorrnaps, complete user control of the graphics objects through<br />

Handle Gmphics tools for designing sophisticated graphics user interfaces, and animation<br />

are now part of <strong>MATLAB</strong>. What is special about <strong>MATLAB</strong>'s graphics<br />

facility is its ease of use and expandability. Commands for most garden-variety<br />

plotting are simple, easy to use, and intuitive. If you are not satisfied with what<br />

you get, you can control and manipulate virtually everything in the graphics window.<br />

This, however, requires an understanding of Handle Graphics, a system of<br />

low-level functions to manipulate graphics objects. In this section, we take you<br />

through the main features of <strong>MATLAB</strong>'s graphics facilities.<br />

6.1 Basic 2-D Plots<br />

The most basic and perhaps most useful command for producing a 2-D plot is<br />

plot ( xvalues, yvalues, 'style-option)<br />

for oncline helP;<br />

type:<br />

'1ielp grCipli:2a ··· ·<br />

where xvalues and yvalues are vectors containing the x- and y-coordinates of points<br />

on the graph and the style-option is an optional argument that specifies the color,<br />

the line style (e.g., solid, dashed, dotted), and the point-marker style (e.g., o, +,<br />

*). All three style options can be specified together. The two vectors xvalues and<br />

yvalues MUST have the same length. Unequal length of the two vectors is the most<br />

common source of error in the plot commaml. The plot function also works with a<br />

single-vector argument, in which case the elements of the vector are plotted against<br />

row or column indices. Thus, for two column vectors x and y each of length n,<br />

plot (x,y)<br />

plot(x,y, '--')<br />

plot (x)<br />

plntR v vmRnR x with a solid line (the default line stylP.),<br />

plots y versus x with a dashed line (more on this below) , and<br />

plots the elements of x against their row index.

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

Saved successfully!

Ooh no, something went wrong!