Arithmatic Operatores On Matrix in Matlab
Arithmatic Operatores On Matrix in Matlab
+ addition
- subtraction
* multiplication
/ division
^ power
‘ complex conjugate transpose
Array arithmetic operations are carried out element by element, and can be used with
multidimensional arrays. The period character (.) distinguishes the array operations from the
matrix operations. However, since the matrix and array operations are the same for addition and
subtraction, the character pairs .+ and .- are not used.
+ Addition, A+B adds A and B. A and B must have the same size, unless one is a scalar. A
scalar can be added to a matrix of any size.
- Subtraction, A-B subtracts B from A. A and B must have the same size, unless one is a
scalar. A scalar can be subtracted from a matrix of any size.
Example 1
Given A and B:
Addition Subtraction
For c a scalar and
Example 2
>>c= 5
>>b= A+c
Matrix multiplication
C = A*B is the linear algebraic product of the matrices A and B. More precisely,
For nonscalar A and B, the number of columns of A must equal the number of rows of B.
Transpose
Matrix multiplication
[ ] [ ]
[ 𝐴 ]= 8 3 7 ,[ 𝐵 ]= 7 2 3 ,
9 −2 9
Matlab command :
1 3 −4
Note: A * B B * A
Array multiplication
.* Array multiplication. A.*B is the element-by-element product of the arrays A and B. A and B must
have the same size, unless one of them is a scalar.
A11 A12 A13 B11 B12 B13 A11 B11 A12 B12 A13 B13
A. B A21 A22 A23 . B21 B22 B23 A21 B21 A22 B22 A23 B23
A31 A32 A33 B31 B32 B33 A31 B31 A32 B32 A33 B33
0 5 0 4 6 2 0 4 5 6 0 2 0 30 0
A. B 8 3 7. 7 2 3 8 7 3 2 7 3 56 6 21
9 2 9 1 3 4 9 1 2 3 9 4 9 6 36
Matlab command:
>>A=[0 5 0;8 3 7;9 -2 9]’
>> B=[4 6 -2;7 2 3;1 3 -4
>> A.*B
Matrix division
Left division, \:
9
Matrix Division
Right division, /:
10
Example: consider the following set of equations, find the solution of the equation:
5x+2y-9z=44
-9x-3y+22=11
6x+7y+32=5
Note: Suppose the determinate of matrix A nonzero
Solution: (using matlab commands)
>>a=[5 2 -9;-9 -3 22;6 7 32]
>>b=[44;11;5]
>>k=a\b
k=
1.0e+03 *
2.4624
-4.1378
0.4436
The result in k represents the values of x,y and z
Array division
./ Array right division. A./B is the matrix with elements A(i,j)/B(i,j). A and B must have the same
size, unless one of them is a scalar.
.\ Array left division. A.\B is the matrix with elements B(i,j)/A(i,j). A and B must have the same
size, unless one of them is a scalar.
Example:
1 16 729 13
Matrix transpose: A' is the linear algebraic transpose of A
1 2 3
4 5 6
7 8 9
MATLAB command:
>> a=[1 2 3;4 5 6;7 8 9];
>>a’
ans =
1 4 7 Note: The transpose of any matrix
2 5 8 switches the column with row
3 6 9