asol = 
how to get inverse ?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
a = [1 2 3];
b = [3 2 1 ].';
c = a*b;
aa = c*pinv(b) ;
i want to answer a = aa but i can't
pleas~~~~
1 Comment
Rik
on 17 Aug 2024
Share a link to this comment
What exactly is your question? Do you want to find out whether a is equal to aa?
Accepted Answer
akshatsood
on 17 Aug 2024
Edited: akshatsood
on 17 Aug 2024
0 votes
Share a link to this answer
Dear @종영
I understand that you are trying to recover the original vector "a" from matrix multiplication. The issue here is that "c" is a scalar, so when you multiply "c" by pseudo-inverse of "b", you do not necessarily get back the original vector "a".
Explanation: The operation "c * pinv(b)" gives you a vector that tries to approximate "a" under the least-squares solution, but it woould not necessarily equal "a" unless certain conditions are met (e.g., "b" is orthogonal).
Solution: To directly recover "a", you need more information than just "c" and "b". However, if you have control over the process, you can ensure that "b" is orthogonal or use other constraints to make this recovery possible. However, without additional information or constraints, "a" cannot be reconstructed from "c * pinv(b)" operation.
I hope this helps.
6 Comments
akshatsood
on 17 Aug 2024
Share a link to this comment
In order to recover the vector "a", the following code should work
a = [1 2 3]; % Original row vector
b = [3 2 1].'; % Column vector
% Create a matrix using the outer product
C = a.' * b.'; % This results in a 3x3 matrix
% Recover 'a' using the pseudo-inverse
aa = round(C * pinv(b.')).'; % This should recover 'a'
% Display the results
disp('Original vector a:');
Original vector a:
disp(a);
1 2 3
disp('Recovered vector aa:');
Recovered vector aa:
disp(aa);
1 2 3
종영
on 17 Aug 2024
Share a link to this comment
Can't the size of C be 1x1?
akshatsood
on 17 Aug 2024
Edited: akshatsood
on 17 Aug 2024
Share a link to this comment
Dear @종영
When "c" is a Scalar:
- "c = a * b" is a scalar resulting from the dot product of "a" and "b".
- "aa = c * pinv(b)" attempts to reconstruct "a" from the scalar "c" and the pseudo-inverse of "b".
Why it Fails:
- The scalar "c" does not contain enough information to reconstruct the vector "a".
- The pseudo-inverse of a vector "b" is a generalized inverse that does not guarantee the reconstruction of the original vector a when multiplied by a scalar.
When "c" is a Matrix:
- c = a.' * b.' results in a matrix (a 3x3 matrix in this answer).
- aa = round(C * pinv(b.')).' attempts to reconstruct "a".
Why it Works:
- The outer product "c" is a full-rank matrix that captures more information about the relationship between "a" and "b".
- The pseudo-inverse operation on b.' (a row vector) can be used to reconstruct "a" when "c" is multiplied by it. This is because the matrix "c" retains the linear transformations needed to recover "a".
I hope this helps.
John D'Errico
on 17 Aug 2024
Edited: John D'Errico
on 17 Aug 2024
Share a link to this comment
You already have a good and fairly complete answer. But let me expand on a few points.
a = [1 2 3];
b = [3 2 1 ].';
c = a*b
c = 10
And as said, there is too little information to reconstruct a from only one piece of information, the constant c. With c == 10, are there other vectors x, such that x*b == 10. In fact, there are infinitely many such vectors. The simplest one is one you will get from pinv, or from lsqminnorm.
a0 = c*pinv(b)
a0 = 1x3
2.1429 1.4286 0.7143
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
a0*b
ans = 10.0000
As you should see, it does correctly return 10 as the result. But it is not the vector you wanted. Since there are infinitely many such possible vectors, what can you expect?
The complete set of all possible solutions can be written as:
syms s t
asol = vpa(c*pinv(b) + [s,t]*sym(null(b.').'),5)
And for some choice of s and t, you would have gotten the vector [1 2 3]. But ANY choice of s and t will still work.
vpa(asol*b,5)
ans = 
I've used only 5 digits here to make it all readable, but do you follow the idea? Had I allowed more precision than only 5 digits, ANY choice of s and t will work.
The one generated by pinv happens to be where s=t=0. (That is essentially by design.) But we can learn what it will take to generate the solution you think was correct.
st = solve(asol(1) == 1,asol(2) == 2,[s,t])
st = struct with fields:
s: 0.91047194823962383245670176555592
t: 2.4552359741203088219207249743343
subs(asol,st)
ans = 
and within some tiny amount of crap (remember, I truncated everything to 5 digits there to make it all readable) you get the result you wanted, for that specific choice of s and t.
Steven Lord
on 17 Aug 2024
Share a link to this comment
With c == 10, are there other vectors x, such that x*b == 10. In fact, there are infinitely many such vectors. The simplest one is one you will get from pinv, or from lsqminnorm.
The simplest in some sense. But as you said, there are others.
a = [1 2 3];
b = [3 2 1 ].';
c = a*b
c = 10
alsoc = [0 0 10]*b
alsoc = 10
alsoc2 = [0 5 0]*b
alsoc2 = 10
alsoc3 = [3 0 1]*b
alsoc3 = 10
If you didn't know a, how could you rule out that a is [0 0 10], [0 5 0], or [3 0 1] instead of [1 2 3]? Either of the vectors used to create alsoc or alsoc2 could be considered "simpler" as they only have one non-zero element, as does the solution returned by \.
a2 = 10/b
a2 = 1x3
3.3333 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
a2*b
ans = 10
John D'Errico
on 17 Aug 2024
Share a link to this comment
Yes, I guess my use of simplest as a description is arguable. Certainly
a = [10/3, 0, 0]
a = [0 0 10]
a = [0 5 0]
or
a = [10/6, 10/6, 10/6]
Would as easily qualify, and are surely simpler by most definitions of the word. They all work as well as any other.
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)