How to find all the non unique solutions in rank deficient system of linear equations in matlab

17 次查看(过去 30 天)
Dears,
I have a sytem of linear equations and it is rank deficient and therfore the solutions are not unique,how to find all the solutions in matlab?
syms x1 x2 x3 x4 x5;
eqn1 = 2 * x1 -x2 + 2*x3-x4+3*x5 == 14;
eqn2 = x1 + 2*x2+3*x3+x4+0*x5 == 15;
eqn3 = x1 + 0*x2 * -2*x3 +0*x3+ -5 * x5 == -10;
[A, B] = equationsToMatrix ([eqn1, eqn2, eqn3], [x1, x2, x3,x4,x5])

回答(1 个)

David Goodmanson
David Goodmanson 2020-5-15
编辑:David Goodmanson 2020-5-15
Hello Zeab,
One solution is
v0 = A\b.
Since A is rank defiicient it has a nonempty null space
nullA = null(A)
which is dimension 5x2. Two column vectors span the null space of A, and by definition A*nullA = 0 . The entire solution is v0 plus an arbitrary linear combination of the column vectors in nullA:
syms x1 x2 x3 x4 x5 c1 c2;
eqn1 = 2 * x1 -x2 + 2*x3-x4+3*x5 == 14;
eqn2 = x1 + 2*x2+3*x3+x4+0*x5 == 15;
eqn3 = x1 + 0*x2 * -2*x3 +0*x3+ -5 * x5 == -10;
[A, B] = equationsToMatrix ([eqn1, eqn2, eqn3], [x1, x2, x3,x4,x5])
nullA = null(A)
v0 = A\B
v0 =
-10
-52/7
93/7
0
0
vextra = v0 + nullA*[c1;c2] % c1,c2 are arbitrary
vextra =
5*c2 - 10
(29*c2)/7 - (5*c1)/7 - 52/7
c1/7 - (31*c2)/7 + 93/7
c1
c2
A*vextra -B % check
ans =
0
0
0

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by