How to find non-zero solutions to underdetermined systems of equations

6 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Torsten
Torsten el 25 de Oct. de 2024
Editada: Torsten el 25 de Oct. de 2024
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)
N = 4×2
-0.5051 0.0193 -0.3585 -0.6051 0.7700 -0.1124 -0.1531 0.7879
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
A*N
ans = 2×2
1.0e-15 * -0.0173 0.0139 0.0833 0.1110
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
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)
Minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
n = 4×1
1.0000 0.6629 -1.5306 0.3624
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
C*n
ans = 2×1
1.0e-09 * 0.8290 -0.2444
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

Más respuestas (0)

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by