Geoscience Reference
In-Depth Information
plot(x,y1,'--')
figure
plot(x,y2,'-')
Instead of plotting both lines in one graph simultaneously, we can also plot
the sine wave, hold the graph and then plot the second curve. h e command
hold is particularly important for displaying data while using dif erent plot
functions, for example if we wish to display the sine of x as a line plot and the
cosine of x as a bar plot.
plot(x,y1,'r--')
hold on
bar(x,y2)
hold off
h is command plots y1 versus x as a dashed red line using 'r--' , whereas y2
versus x is shown as a group of blue vertical bars. Alternatively, we can plot
both graphics in the same Figure Window but in dif erent plots using subplot .
h e syntax subplot(m,n,p) divides the Figure Window into an m -by- n array
of display regions and makes the p th display region active.
Fig. 2.4 Screenshot of the MATLAB Figure Window showing two curves in dif erent colors and
line types. h e Figure Window allows editing of all elements of the graph at er selecting Edit
Plot from the To o l s menu. Double clicking on the graphics elements opens an options window
for modifying the appearance of the graphics. h e graphics can be exported using Save as
from the File menu. h e command Generate Code from the File menu creates MATLAB code
from an edited graph.
Search WWH ::




Custom Search