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 commentaires

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

Connectez-vous pour commenter.

 Réponse acceptée

John D'Errico
John D'Errico le 3 Juil 2017
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 commentaires

Damian Wierzbicki
Damian Wierzbicki le 3 Juil 2017
Thank you :)
Damian Wierzbicki
Damian Wierzbicki le 4 Juil 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 le 4 Juil 2017
Thank you !

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by