0% found this document useful (0 votes)
35 views

Matrix and Array Operations

This document describes objectives and operations that can be performed on matrices in MATLAB. It discusses reshaping matrices, creating utility matrices, arithmetic operations like addition and multiplication, relational operations like less than and equal to, and logical operations like AND and OR. Matrix operations covered include addition, subtraction, transposition, multiplication by scalars and between matrices and vectors.

Uploaded by

raj aryan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Matrix and Array Operations

This document describes objectives and operations that can be performed on matrices in MATLAB. It discusses reshaping matrices, creating utility matrices, arithmetic operations like addition and multiplication, relational operations like less than and equal to, and logical operations like AND and OR. Matrix operations covered include addition, subtraction, transposition, multiplication by scalars and between matrices and vectors.

Uploaded by

raj aryan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

EXPERIMENT NO.

MATRIX OPERATIONS
OBJECTIVES

 Matrix addition, subtraction, conjugation,


transposition,
 matrix multiplication by a scalar,
 vector-vector multiplication,
 Matrix-vector multiplication,
 Matrix-Matrix multiplication.
General Matrix Operators

 Reshaping Matrices
 Matrices can be reshaped into a vector or any other
appropriately sized matrix
 As a vector Stacked to single coloumn vector. E.g. b=A(:)
 As a differently sized matrix If a matrix A is an mXn matrix
then it can be reshaped to pXq , as long as mXn = pXq with the
command reshape(A,p,q)
 Utility Matrices
 eye
 zeros
 ones
 rand
 randn
 diag
 diag(A,1)
 rot90
 fliplr
 flipud
 tril
 triu
 Reshape
 Disp()
 Length()
 Size()
Matrix & Array Operations

 Arithmetic Operations
 MATLAB allows operators like +(addition), -(Substraction),
*(Multiplication), /(Division) ^ (Exponentiation)
 A+B or A-B valid if A&B are of same size.

 A*B valid if A’s no. of coloumns equals B’s no. of rows.

 A/B valid for same sized square matrices and = A.B-1

 A\B used to solve matrix equation Ax=b. A\B= inv(A)*b.


 E.g. 5/3=1.66 5\3=0.6(5^-1*3)
Matrix & Array Operations

 Relational Operations
 < <= > >= == ~=
Ex.
If x=[1 5 3 7] and y=[0 2 8 7]
Then k=x<y results in k=[0 0 1 0]
k=x<=y results in k=[0 0 1 1]
K= x>y [1 1 0 0]
K= x>=y [1 1 0 1]
K= x == y [0 0 0 1]
K= x~=y [1 1 1 0]
These are normally used in conditional statements as if-then-else
Matrix & Array Operations

 Logical Operations
 & | ~ xor
 Ex. Let x=[0 5 3 7] and y=[0 2 8 7]
 Then m=(x>y)&(x>4) results m=[0 1 0 0]
 N=x|y [

You might also like