Matrix multiplication from the right with inverse matrix

a=[-0.7398 1.638; 1.4522 -4.258; 2.192 5.42];
r=[2.74 1.6; 0 6.9; 0 0];
u=a\r;
u
I know it's a trivia question but I'm just a begginer and it's really bugging me out.
I have this equation: U=R*A^-1 . From the documentation I found out that u=a/r calculates U=A^-1*R. I've been spilling my brains out trying to find a way to get this equation right but some of the possible answers I found only made me more confused.
Can someone please show me a possible way to implement this equation U=R*A^-1 in matlab and to work properly?

Réponses (2)

Ameer Hamza
Ameer Hamza le 18 Nov 2020
Modifié(e) : Ameer Hamza le 18 Nov 2020
You can use mrdivide /
u = r/a
The equation is equivalent to . mrdivide is used for such equations.

2 commentaires

George Rosca
George Rosca le 18 Nov 2020
Modifié(e) : George Rosca le 18 Nov 2020
u=r/a returns a 3x3 matrix
u=a\r (U=A^-1*R) returns a 2x2 matrix, and even though it's not correct because I need the multiplication from the right, I believe it's closer to reality in terms of size.
Edit: u=r/a returns a 3x3 matrix but with the first column and the last line full of zeros, I tend to believe that it might be correct but I need to delete the respective column and line, could this be true?
No. If you delete the zero column and the zero row, then you CANNOT form the product of a 2x2 matrix times a 3x2 matrix in that order. This is basic linear algebra, how you multiply matrices.

Connectez-vous pour commenter.

John D'Errico
John D'Errico le 18 Nov 2020
Modifié(e) : John D'Errico le 18 Nov 2020
a is a 3x2 matrix. No matter what, you cannot compute the inverse of a, so
U=R*A^-1
is meaningless.
I assume you want to solve for the matrix U, such that
U*a == r
as closely as possible. That is, norm(U*a-r) is the smallest possible value over all matrices U?
a=[-0.7398 1.638; 1.4522 -4.258; 2.192 5.42];
r=[2.74 1.6; 0 6.9; 0 0];
In the help for / (known as mrdivide if you look at the function itself) we see:
>> help /
/ Slash or right matrix divide.
A/B is the matrix division of B into A, which is roughly the
same as A*INV(B) , except it is computed in a different way.
So, if you could invert the matrix you call a, we would perform your task as:
U = r/a;
Does u have the desired property? Yes.
norm(U*a- r)
ans = 9.9301e-16
As we see, the norm is effectively zero, or as close as we could come in floating point arithmetic.
r
r = 3×2
2.7400 1.6000 0 6.9000 0 0
U*a
ans = 3×2
2.7400 1.6000 -0.0000 6.9000 0 0
The matrix U is a 3x3 matrix. as in order for the sizes of the matrices to conform for matrix multiplication, it must have that size.
U
U = 3×3
0 0.6593 0.8132 0 -0.8791 0.5824 0 0 0
As you can see, U is 3x3. Remember how you multiply matrices. If you wish to form the product U*a, where a is 3x2, and have the result be a matrix of size 3x2 also, then U MUST be a 3x3 matrix.

Produits

Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by