11.07.2015 Views

MatlabNotes

MatlabNotes

MatlabNotes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Colours Line Styles/symbolsy yellow . pointm magenta o circlec cyan x x-markr red + plusg green - solidb blue * starw white : dottedk black -. dashdot-- dashedThe number of available plot symbols is widerthan shown in this table. Use help plot toobtain a full list. See also help shapes.The command clf clears the current figure whileclose(1) will close the graphics window labelled“Figure 1”. To open a new figure windowtype figure or, to get a window labelled“Figure 9”, for instance, type figure (9). If“Figure 9” already exists, this command willbring this window to the foreground and thenext plotting commands will be drawn on it.13.4 Multi–plotsSeveral graphs may be drawn on the same figureas in>> plot(x,y,’k-’,x,cos(3*pi*x),’g--’)A descriptive legend may be included with>> legend(’Sin curve’,’Cos curve’)which will give a list of line–styles, as they appearin the plot command, followed by the briefdescription provided in the command.For further information do help plot etc.The result of the commands>> plot(x,y,’k-’,x,cos(3*pi*x),’g--’)>> legend(’Sin curve’,’Cos curve’)>> title(’Multi-plot’)>> xlabel(’x axis’), ylabel(’y axis’)>> gridis shown in Fig. 3. The legend may be movedeither manually by dragging it with the mouseor as described in help legend.Fig. 3: Graph of y =sin3⇡x and y = cos 3⇡xfor 0 apple x apple 1 using h =0.01.13.5 HoldA call to plot clears the graphics window beforeplotting the current graph. This is not convenientif we wish to add further graphics to thefigure at some later stage. To stop the windowbeing cleared:>> plot(x,y,’r-’), hold on>> plot(x,y,’gx’), hold off“hold on” holds the current picture; “hold off”releases it (but does not clear the window, whichcan be done with clf). “hold” on its own togglesthe hold state.13.6 Hard CopyTo obtain a printed copy select Print from theFile menu on the Figure toolbar.Alternatively one can save a figure to a file forlater printing (or editing). A number of formatsis available (use help print to obtain alist). To save the current figure in “EncapsulatedColor PostScript” format, issue the Matlabcommandprint -depsc fig1which will save a copy of the image in a filecalled fig1.eps.print -f4 -djpeg90 figbwill save figure 4 as a jpeg file figb.jpg at aquality level of 90. It should be borne in mindthat neither command (despite its name) sendsthe file to a printer.13

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

Saved successfully!

Ooh no, something went wrong!