Linear least squares overdetermined system
6 ビュー (過去 30 日間)
古いコメントを表示
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!
回答 (1 件)
Bjorn Gustavsson
2019 年 9 月 24 日
編集済み: Bjorn Gustavsson
2019 年 9 月 25 日
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 件のコメント
Bjorn Gustavsson
2019 年 9 月 24 日
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.
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!