Graphics Programs Reference
In-Depth Information
ans =
8
10
12
4
6
8
>> A*B'
% Matrix multiplication
ans =
50
8
122
17
>> A*B % Matrix multiplication fails
??? Error using ==> * % due to incompatible dimensions
Inner matrix dimensions must agree.
There aretwo division operators in MATLAB:
/
Right division
\
Left division
If
a
and
b
arescalars, the right division
a/b
results in
a
dividedby
b
, whereas the left
divisionisequivalentto
b/a
. In the case where
A
and
B
are matrices,
A/B
returns the
solution of
X*A = B
and
A
B
yields the solution of
A*X = B
.
Oftenwe need to apply the
*
,
/
and
ˆ
operationstomatrices in an element-by-
elementfashion. Thiscan be done by preceding the operatorwith aperiod (
.
) as
follows:
\
.*
Element-wise multiplication
./
Element-wise division
.ˆ
Element-wise exponentiation
For example, the computation
C
i j
=
A
i j
B
i j
can be accomplishedwith
>>A=[123;456];B=[789;012];
>>C=A.*B
C=
7
16
27
0
5
12
Search WWH ::
Custom Search