Matlab Notes Day-2
Matlab Notes Day-2
1.Arithmetic operations:
Matrix Multiplication:
Let matrix a and b
a*b = simple matrix multiplication.
a.*b= element to element multiplication.
a^2 = matrix a*a
a.^2 =matrix a.*a
2. Concatenation of Matrices
Another method
Note: order of matrix must keep in mind other wise cat will not happen.
Note : means all row or all column; if a(:,[3 6]) means all rows and 3 and 6th coulmn.
a(4) = [ ]
x(2,:)=[ ]
x(:,3)=[ ]
Let a be an matrix.
diag(a) = column vector of diagonal element.
NOTE: diagonal of any row or column vector (of 4 elements)= diag matrix of 4 x 4 size.
Let a matrix A of 3 x 3
A) we want to change specific element like at 2nd row and 3rd col => A(2,3) = 0
B) We want to Add element to only 4 row => A(4,:) = [1 2 3]
C) We want to add element only to 4 col => A(:,4) = [3 4 5]
D) We want to add matrix at 4 and 5 row => A(2:3,:)=[1 2 3:3 4 5]
E) We want to change elements from 2 to 3 row and 2 to 3 col => A(2:3,2:3)=[1 1;2 2]
9. Random Function