next Creating and reading .wav files
up Music 270a: Matlab Tutorial 2
previous Creating a sinusoid


Plotting

If we want to plot our resulting vector x, we can execute the command plot(x). This isn't very meaningful however, because it doesn't give us any time information--it just plots the samples from 0:length(x). An alternative command would be to plot the sinusoid with respect to time using the command plot(nTs, x) where nTs is the discretized time variable, with a sampling period of Ts.

It is also possible to plot two things on the same figure. For example, if we want to see our sinusoid as a continuous line, we would plot as above (and Matlab will interpolate between the points). We may, in addition, want to see where the samples lie, in which case we can plot in the following way:

plot(nTs, x, nTs, x, 'o', 'MarkerFaceColor', black, 'MarkerEdgeColor', black);
Therefore you can use the same plot function to plot multiple things, including additional functions (for example, if you want to see two different sinusoids at the same time).


next Creating and reading .wav files
up Music 270a: Matlab Tutorial 2
previous Creating a sinusoid

``Music 270a: Digital Audio Processing'' by Tamara Smyth, Department of Music, University of California, San Diego (UCSD).
Download PDF version (matlabtut2.pdf)
Download compressed PostScript version (matlabtut2.ps.gz)

Copyright © 2013-01-08 by Tamara Smyth.
Please email errata, comments, and suggestions to Tamara Smyth<trsmyth@ucsd.edu>