Linear least squares overdetermined system

4 views (last 30 days)
Hello all,
I was hoping for some help solving the following;
k1*x = s1
k2*y = s2
x+y = s3
Whereby k1,k2 are scalar multipliers and x, y ,s_i are 448x448x10 matrices.
AKA I'm solving 448x448x10 sets of 3 equations.
I'm not sure the syntax or correct method to enter into matlab.
?linlsq vs solve vs other?
Thank you!

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 24 Sep 2019
Edited: Bjorn Gustavsson on 25 Sep 2019
If I understand your problem correct you want to solve a reasonably large number of very small linear systems?
In that case you have a problem of the type:
A = [k1,0;0,k2;1 1];
A*[x;y] = [s1;s2;s3];
where you want to solve for x and y. Since you have a large number of so small equations to solve, why not calculate the least-square estimator explicitly?
A_dagger = inv(A'*A)*A';
The general advice is not to do this, but you have one 3x2 matrix to "invert" and on the order of 2e6 equations to solve.
With an explicit inverse, A_dagger, you can write the all the solutions for x and y explicitly. If k1 and k2 are numerically known you're set, if you have access to the symbolic toolbox it too lets you solve for A_dagger. This ought to be the most efficient way to solve the problem the way I've understood it.
HTH
  1 Comment
Bjorn Gustavsson
Bjorn Gustavsson on 24 Sep 2019
You can one-line this if you can manage to reshape this properly:
XY = A\[s1(:),s2(:),s3(:)]';
This will give you XY as a [2 x (448*448*10)] array, from which you'd get all x from the first row and y from the second. You'd have to reshape them to your prefered 448x448x10 after that. I'd still go with the above solution.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!