Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Matrix equation solution keep giving only structure of the array not the value
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
new =
[ (29*y2)/5 - (7*z2)/10, 7*z2, -7*y2]
>> dif=MRA-Mprll
dif =
-0.1337 -9.7234 1.3349
>> syms y2 z2
>> eqn = new - dif ==0 ;
>> solve(eqn)
ans =
struct with fields:
y2: [0×1 sym]
z2: [0×1 sym]
0 Commenti
Risposte (1)
John D'Errico
il 8 Set 2020
As I explained in my comment to @Vasishta Bhargava, this is a problem with 3 equations, but only 2 unknowns. It is known as an over-determined problem. As such, it likely never has an exact solution, so solve cannot solve it.
Typically, one might use a tool like a linear regression, to find y2 and z2 that will minimize the errors in the three equations at once. I'll be lazy here and just use fminsearch.
new = @(yz) [(29*yz(1))/5 - (7*yz(2))/10, 7*yz(2), -7*yz(1)];
dif = [-0.1337 -9.7234 1.3349];
obj = @(yz) norm(new(yz) - dif);
yz = fminsearch(obj,[1 1])
yz =
-0.190698528012633 -1.38904515739705
How well did it work?
[new(yz);dif]
ans =
-0.133719852295332 -9.72331610177938 1.33488969608843
-0.1337 -9.7234 1.3349
quite well in fact.
I could also have use a direct linear regression.
[A,B] = equationsToMatrix(eqn);
double(A)\double(B)
ans =
-0.190698604595212
-1.38905731126807
So the same answer, but this time it is more precise, since fminsearch uses a tolerance.
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!