How to find non-zero solutions to underdetermined systems of equations
23 views (last 30 days)
Show older comments
fa wu
on 25 Oct 2024 at 10:15
Commented: fa wu
on 25 Oct 2024 at 16:14
I am solving an underdetermined system of equations and Matlab gives me a zero vector. Zero vector is indeed a solution to the underdetermined system of equations, but it is not helpful. I would like to get a non-zero solution. It would be best if I could specify the positive or negative values of the components of the solution vector. For example, x1>0
A=[0.719600000000000,0.069400000000000,0.526400000000000,0.110700000000000;1.833200000000000,0.377900000000000,1.469000000000000,0.454700000000000];
b=[0;0];
x = A\b
0 Comments
Accepted Answer
Torsten
on 25 Oct 2024 at 11:31
Edited: Torsten
on 25 Oct 2024 at 11:48
The null() function gives you a basis for ker(A):
A=[0.719600000000000,0.069400000000000,0.526400000000000,0.110700000000000;1.833200000000000,0.377900000000000,1.469000000000000,0.454700000000000];
N = null(A)
A*N
So every linear combination of these two vectors will give a vector n with A*n = 0.
"lsqlin" could be used instead if you want to set lower and upper bounds in the coordinates of n. But note that it might happen that no solution exists.
The following code solves for a vector with positive first component n1:
C=[0.719600000000000,0.069400000000000,0.526400000000000,0.110700000000000;1.833200000000000,0.377900000000000,1.469000000000000,0.454700000000000];
d=[0;0];
Aeq = [1 0 0 0];
beq = 1;
n = lsqlin(C,d,[],[],Aeq,beq)
C*n
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!