My equation looks as follows: Y = x1*A + x2*B + x3*C, where Y, A, B, C are matrices of the 260x100 dimension and I want to solve for x1 , x2 , x3 but I'm not sure how to approach this in Matlab. Could someone share some tips with me, please ?

2 Kommentare

John D'Errico
John D'Errico am 3 Jul. 2017
Are x1,x2,x3 scalar unknowns? Are they arrays?
Damian Wierzbicki
Damian Wierzbicki am 3 Jul. 2017
They're scalar unknowns

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

John D'Errico
John D'Errico am 3 Jul. 2017

0 Stimmen

So you have only 3 unknowns.
x123 = [A(:),B(:),C(:)]\Y(:);
This returns a vector of length 3, which is the linear least squares solution.

4 Kommentare

Damian Wierzbicki
Damian Wierzbicki am 3 Jul. 2017
Thank you :)
Damian Wierzbicki
Damian Wierzbicki am 4 Jul. 2017
What if I had another equation that looks as follows: Z = x1*D + x2*E + x3*F, where Z, D, E, F are again matrices of the same size as above and x1, x2, x3 are defined as above. When I solve them separately, they give me two different set of solutions, as expected. How can I combine the two equation, so I get one set of solutions for both systems ? Adding both sides of the equation and then solving for x1, x2, x3 ? I'd be really grateful if you could help.
x123=[A(:),B(:),C(:);D(:),E(:),F(:)]\[Y(:);Z(:)];
Best wishes
Torsten.
Damian Wierzbicki
Damian Wierzbicki am 4 Jul. 2017
Thank you !

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by