12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

In this case we used plot to plot one vector against another. Theelements <strong>of</strong> the vectors were plotted in order <strong>and</strong> joined by straight linesegments. There are many options for changing the appearance <strong>of</strong> a plot.For example:plot(x,y,’r-.’)will join the points using a red dash-dotted line. Other colours you canuse are: ’c’, ’m’, ’y’, ’r’, ’g’, ’b’, ’w’, ’k’, which correspond tocyan, magenta, yellow, red, green, blue, white, <strong>and</strong> black. Possible linestyles are: solid ’-’, dashed ’--’, dotted ’:’, <strong>and</strong> dash-dotted ’-.’.To plot the points themselves with symbols you can use: dots ’.’, circles’o’, plus signs ’+’, crosses ’x’, or stars ’*’, <strong>and</strong> many others (typehelp plot for a list). For example:plot(x,y,’bx’)plots the points using blue crosses without joining them with lines, <strong>and</strong>plot(x,y,’b:x’)plots the points using blue crosses <strong>and</strong> joins them with a blue dottedline. Colours, symbols <strong>and</strong> lines can be combined, for example, ’r.-’,’rx-’ or ’rx:’.4.1 Plotting Many LinesTo plot more than one line you can specify more than one set <strong>of</strong> x <strong>and</strong>y vectors in the plot comm<strong>and</strong>:plot(x,y,x,2*y)On the screen Matlab distinguishes the lines by drawing them in differentcolours. If you need to print in black <strong>and</strong> white, you can differentiatethe lines by plotting one <strong>of</strong> them with a dashed line:plot(x,y,x,2*y,’--’)c○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!