There are two operators allowing to divide in Matlab:
- The right division represented by the symbol / (slash)
- The left division represented by the symbol \ (Backslash)
These two operators differ from each other
Using numbers, the right division will be the conventional division we all day make use of, so
Contrary to the right division, the left division reverse the division, meaning
Matrix division in Matlab
The right Matrix divide
Let’s consider two Matrices A and B
Using the right division
Matlab code
A=[1 2 ; 2 2]; B=[3 2 ; 1 1]; A/B % You can also use A*inv(B)
which returns
rewritten, it will look like this
The left Matrix divide
The right matrix divide is roughly the same as
Which leads to a complete different result from the preceding operator.
This technique can be used to quickly compute the solution of the equation
So, using our early defined matrices
will be written
A=[1 2 ; 2 2]; B=[3 2 ; 1 1]; A\B % You can also use inv(A)*B
which returns
Which rewritten will look like
The Matrix division, element by element
We thought it will be also necessary you have a grip on the element-by-element Matrix division in Matlab
To divide Matrices, element-by-element, the following formula is useful
Where
The code
A./B