asol = 
how to get inverse ?
Al momento, stai seguendo questa domanda
- Vedrai gli aggiornamenti nel tuofeed del contenuto seguito.
- Potresti ricevere delle e-mail a seconda delle tuepreferenze per le comunicazioni.
Si è verificato un errore
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
Mostra commenti meno recenti
0 voti
Condividi un link a questa domanda
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 Commento
Rik
il 17 Ago 2024
Condividi un link a questo commento
What exactly is your question? Do you want to find out whether a is equal to aa?
Risposta accettata
akshatsood
il 17 Ago 2024
Modificato: akshatsood
il 17 Ago 2024
0 voti
Condividi un link a questa risposta
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 Commenti
akshatsood
il 17 Ago 2024
Condividi un link a questo commento
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
종영
il 17 Ago 2024
Condividi un link a questo commento
Can't the size of C be 1x1?
akshatsood
il 17 Ago 2024
Modificato: akshatsood
il 17 Ago 2024
Condividi un link a questo commento
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
il 17 Ago 2024
Modificato: John D'Errico
il 17 Ago 2024
Condividi un link a questo commento
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
il 17 Ago 2024
Condividi un link a questo commento
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
il 17 Ago 2024
Condividi un link a questo commento
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.
Più risposte (0)
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Tag
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)
