P. 1
Introduction to Matlab

Introduction to Matlab

|Views: 261|Likes:
Published by thesuperleo

More info:

Published by: thesuperleo on Sep 28, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/20/2011

pdf

text

original

The usual multiplication sign * has special meaning in Matlab. Because everything in Matlab
is a matrix, * means matrix multiply. So if A is a 3x3 matrix and B is another 3x3 matrix,
then AB will be their 3x3 product. Similarly, if A is a 3x3 matrix and C is a 3x1 matrix
(column vector) then AC will be a new 3x1 column vector. And if you want to raise A to
a power by multiplying it by itself n times, you just use

A^n

For a language that thinks everything in the world is a matrix, this is perfectly natural. Try

A*B

A*[1;2;3]

A^3

But there are lots of times when we don’t want to do matrix multiplication. Sometimes we
want to take two big arrays of numbers and multiply their corresponding elements together,
producing another big array of numbers. Because we do this so often (you will see many
examples later on) Matlab has a special symbol for this kind of multiplication:

.*

For instance, the dot multiplication between the arrays [a,b,c] and [d,e,f] would be the
array [a*d,b*e,c*f]. And since we might also want to divide two big arrays this way, or
raise each element to a power, Matlab also allows the operations

./ and .^

For example, try

[1,2,3].*[3,2,1]

[1,2,3]./[3,2,1]

[1,2,3].^2

These “dot” operators are very useful in plotting functions and other kinds of signal pro-
cessing. ( You are probably confused about this dot business right now. Be patient. When
we start plotting and doing real calculations this will all become clear.)

14

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->