Division of Matrices in MatLab: Explained

In summary, when working with matrices in MatLab, you cannot directly divide one matrix by another. Instead, MatLab uses various operations, such as finding the inverse or conjugate transpose, to solve the system of equations in the least squares sense and obtain a solution. This may be confusing for those new to MatLab, but resources such as the help file and the Moore-Penrose pseudoinverse can provide a better understanding of the process.
  • #1
magda3227
19
0
As far as I know, matrices cannot be divided, you have to multiply one matrix by the inverse of the other...I believe.

However, I am converting MatLab code into ANSI C and MatLab apparently divides two matrices. An example is the following...

>>A=[1.5708 1.5708];
B=[0.4937 0.7652];
A/B

ans =

2.3846


I have no idea how MatLab generated this answer. I try to find the inverse of the second matrix, but since it is a non-square matrix, MatLab denies my request. Can anyone aid me in figuring out how such an answer was calculated? Thank you in advance.
 
Physics news on Phys.org
  • #3
I looked through that as well, but it says that it is equal to A*inverse(B)...but like I said, I cannot calculate the inverse of B. MatLab itself won't do it for me if I write the command line, so I don't see how it completes the matrix division calculation without finding the inverse of B.

It also says that it is equivalent to A/B = (B'\A')'. But again, You have to divide two matrices, only here, it is the conjugate transposes of the two. So even if I find the conj. transposes of the two (which will basically move the rows into columns), I still cannot find out how they got 2.3846 as an answer.
 
  • #4
Presumably you need to decipher:
If A is an m-by-n matrix with m ~= n and B is a column vector with m components, or a matrix with several such columns, then X = A\B is the solution in the least squares sense to the under- or overdetermined system of equations AX = B. The effective rank, k, of A is determined from the QR decomposition with pivoting (see Algorithm for details). A solution X is computed that has at most k nonzero components per column.

It's too late here for me to get my head around that, but someone else will probably come along who can.
 
  • #6
maze said:

THANKS!

I had a look at this before, but I didn't really understand it, so I looked for simpler explanations. It took my stupid self about 30 minutes to fully comprehend what it was saying. I really had to read slowly. lol. It is very brief, but rightfully so. Not much more explaining needed once you get it. Thanks a bunch.
 

1. What is the purpose of dividing matrices in MatLab?

The purpose of dividing matrices in MatLab is to perform mathematical operations on matrices to solve problems in various fields such as engineering, physics, and economics. It allows for the manipulation of data and the analysis of relationships between different variables.

2. How do you divide matrices in MatLab?

In MatLab, dividing matrices is done using the 'slash' operator (/) or the 'mrdivide' function. The 'slash' operator performs right matrix division, while the 'mrdivide' function can handle both right and left matrix division. Both methods require the matrices to have compatible dimensions for division to be possible.

3. What are the different types of division in MatLab?

There are two types of division in MatLab - right division and left division. Right division is performed using the 'slash' operator (/) and results in dividing the first matrix by the second matrix. Left division is performed using the 'backslash' operator (\) or the 'mldivide' function and results in dividing the second matrix by the first matrix.

4. How does MatLab handle division by zero?

When dividing matrices in MatLab, if any element in the divisor matrix is equal to zero, the result will be an 'Inf' (infinity) or 'NaN' (not a number) value. This is because division by zero is undefined in mathematics. It is important to check for and handle these values in order to avoid errors in calculations.

5. Can I divide matrices with different dimensions in MatLab?

No, in order to divide matrices in MatLab, they must have compatible dimensions. This means that the number of columns in the first matrix must be equal to the number of rows in the second matrix. If the dimensions are not compatible, MatLab will return an error. In some cases, the matrices can be transposed to make them compatible for division.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
742
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • Computing and Technology
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Precalculus Mathematics Homework Help
Replies
10
Views
2K
Back
Top