Matrix multiplication from the right with inverse matrix
119 views (last 30 days)
Show older comments
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?
0 Comments
Answers (2)
Ameer Hamza
on 18 Nov 2020
Edited: Ameer Hamza
on 18 Nov 2020
You can use mrdivide /
u = r/a
The equation is equivalent to . mrdivide is used for such equations.
2 Comments
John D'Errico
on 18 Nov 2020
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.
John D'Errico
on 18 Nov 2020
Edited: John D'Errico
on 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)
As we see, the norm is effectively zero, or as close as we could come in floating point arithmetic.
r
U*a
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
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.
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!