solve overdetermined linear system
9 次查看(过去 30 天)
显示 更早的评论
Hello. I need to solve overdetermined linear system A*x=B, where x is [a1 a2 a3 a4 a5]. I got a solution with command
inv(A'*A)*A'*B;
but the answer is not what I need, because i have a theoretical solution for this problem. Can I somehow set the initial approximation to get the solution I need?
0 个评论
回答(1 个)
John D'Errico
2017-12-27
First of all, DON'T USE THAT SOLUTION!!!!!!!! That is a bad idea, because it is terrible when applied to moderately ill-posed problems.
Instead, use
coef = A\b;
This will be more accurate.
You say that the answer is not what you wanted. Too bad. You cannot set an initial start point for a problem that has a unique solution.
An alternative solution is to use lsqr.
coef = lsqr(A,b);
You can set the start point for lsqr. From the help for lsqr...
X = lsqr(A,B,TOL,MAXIT,M1,M2,X0) specifies the P-by-1 initial guess. If
X0 is [] then lsqr uses the default, an all zero vector.
But as long as A is full rank, then you will get the same solution, no matter what the start point.
So, is A of less than full rank? If so, then the solution is non-unique, and there are infinitely many equally good solutions.
If you have additional information about the problem, then you need to explain what it is.
5 个评论
John D'Errico
2017-12-27
编辑:John D'Errico
2017-12-27
I cannot run your code though, because I do not know what input to provide.
Your .mat file does not contain A and B, which is all that we need here for the moment.
But if A has rank 2 AND it has 2 columns, then this explains why you get the same answer from both backslash and lsqr. It will be of full rank. If A had 3 or 4 columns and 30-40 rows, and still was rank 2, then backslash and lsqr can return different results, because there will be infinitely many results. So I think you are trying the case where A has 2 columns.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Stress and Strain 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


