next Scripting and creating M-files
up Music 270a: Matlab Tutorial 1
previous Vectors and Matrices


Vector Operations

Operations applied to variables can also be applied to vectors however some care must be taken. Create the following two vectors:

>> a = [5 6 7]
>> b = [1 2 3]

Try adding the vectors.

Now try multiplying the two vectors. You will get an error since Matlab is trying to do Matrix multiplication and is expecting the number of rows in a to equal the number of columns in b. To perform multiplication element by element, you must use a dot with the multiplication operator, ``.*''. This is also true for the division and exponent operator.


next Scripting and creating M-files
up Music 270a: Matlab Tutorial 1
previous Vectors and Matrices

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

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