Overdetermined system of equations

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 Comments

Are x1,x2,x3 scalar unknowns? Are they arrays?
They're scalar unknowns

Sign in to comment.

 Accepted Answer

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 Comments

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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!