solve overdetermined linear system
Show older comments
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?
Answers (1)
John D'Errico
on 27 Dec 2017
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 Comments
Alexandr Fedorov
on 27 Dec 2017
John D'Errico
on 27 Dec 2017
Edited: John D'Errico
on 27 Dec 2017
You have told me only that A has rank of 2. Not what the size of A is. IS A FULL RANK? How many times must I ask that?
Ok, so your call to lsqr tells me that A has nr-1 columns. Of course, you do not tell me what nr is.
Then you tell me that A has rank 2. Before, you told me the problem is over determined. Therefore there are more than nr-1 rows in A. But is nr 3? If it is, then A is of full rank.
IF A IS FULL RANK, THEN THERE IS ONLY ONE SOLUTION. IT IS UNIQUE. So it really does not matter what method you use on a full rank matrix A. Just wanting a different solution is irrelevant, at least unless you possess good wanding skills. How is your magic?
So if you want help, then best would be to provide the matrix A and vector B. Put them in a .mat file, and attach it to a comment using the paper clip. Then explain why you think that the solution you have posed is a solution. You have claimed theory here, but that does not mean I have any reason to believe or accept your claim. Perhaps your theory is even correct, but you created the matrices A or B incorrectly.
Alexandr Fedorov
on 27 Dec 2017
Edited: Alexandr Fedorov
on 27 Dec 2017
John D'Errico
on 27 Dec 2017
Edited: John D'Errico
on 27 Dec 2017
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.
Alexandr Fedorov
on 27 Dec 2017
Edited: Alexandr Fedorov
on 27 Dec 2017
Categories
Find more on Stress and Strain in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

