MatLab Operators
Operators📈 Overview
- Arithmetic Operations
- Relational Operations
- Logical Operations
- Set Operations
- Bit-Wise Operations
Arithmetic Operators
+, -, *, /, ^, ()
Order of Operation
() > ^ > *, / > +-
Notes:
- A*b multiply all elements of A with scalar b
A^n
A to the power n
A.^n
Multiply Each Element of Vector by nth power
A.*B
Multiply Consecutive elements of Matrix A & B
Matrix multiplication (A*B )
Given two Matrix & then matrix Where
Dot product/ Inner Product of Vector(A.B)
RowVector(1n) Column Vector(n1) = Scalar()11
Outer Product of Vector (A⊗B)
Column Vector(n1) RowVector(1n) = Matrix(nn)
RightDivide (./)
A./B : divide all elements of A with corresponding elements of B
A./b : divide all elements of A with vector b
Left Divide (.)
A.\B : divide all elements of B with corresponding elements of A
b.\B : divide all elements of B with vector b
Relational Operators
<, > , <=, >=, ==, ~=
- A>B - return array of 1,0 by comparing each elements of A with B -A*b - return array of 1,0 by comparing each elements in A & b
Complex Numbers
- >, <, >= <= compare only the real part
- == , ~= test both real and imaginary parts.
Undefined values:
- Inf == other Inf values. -NaN ~= numeric value, including other NaN values.
- NaT ~= datetime value, including other NaT values.
- Undefined ~= any other categorical value, including other undefined elements.
Logical Operators
- Assert: true, false
- Logic : |, &, ~, xor
- Short Circuit: ||, &&,
- Logical : islogical, logical
- find, all, any
x = v1(v1<4 & v1>2)
x = all value of v1 between 2 & 4
- L = logical(A) converts A into an array of logical values.
- Any nonzero element of A is converted to logical 1 (true) and zeros are converted to logical 0 (false).
- Complex values and NaNs cannot be converted to logical values and result in a conversion error.
