solving systems of equations but returns empty solutions

3 Ansichten (letzte 30 Tage)
Nicky
Nicky am 21 Jul. 2020
Verschoben: Walter Roberson am 30 Aug. 2024
Hi, I am using solve in MATLAB to solve a system of equations where the code is given below and the right hand sides of each equation are actually given numerical values. I wonder why there is empty solutions in sol even there is no error occurred? Thank you for your kind help.
syms x1 x2 x3 y1 y2 y3 z1 z2 z3 u1 u2 u3 v1 v2 v3
eqns = [x1 + y1 + z1 + u1 + v1 == 5*E_e(1,1),...
x2 + y2 + z2 + u2 + v2 == 5*E_e(2,1),...
x3 + y3 + z3 + u3 + v3 == 5*E_e(3,1),...
x1*x1 + y1*y1 + z1*z1 + u1*u1 + v1*v1 == 5*E_ee(1,1),...
x1*x2 + y1*y2 + z1*z2 + u1*u2 + v1*v2 == 5*E_ee(1,2),...
x1*x3 + y1*y3 + z1*z3 + u1*u3 + v1*v3 == 5*E_ee(1,3),...
x2*x2 + y2*y2 + z2*z2 + u2*u2 + v2*v2 == 5*E_ee(2,2),...
x2*x3 + y2*y3 + z2*z3 + u2*u3 + v2*v3 == 5*E_ee(2,3),...
x3*x3 + y3*y3 + z3*z3 + u3*u3 + v3*v3 == 5*E_ee(3,3)];
vars = [x1,x2,x3,y1,y2,y3,z1,z2,z3];
sol = solve(eqns,vars);

Antworten (2)

Ayush Modi
Ayush Modi am 30 Aug. 2024
Hi Nicky,
The reason "solve" function is returning an empty solution is because the set of equations you are trying to solve does not have a valid symbolic solution.
You can read the following MATLAB Answer threads for detailed explanations:
Hope this helps

Walter Roberson
Walter Roberson am 30 Aug. 2024
Verschoben: Walter Roberson am 30 Aug. 2024
It is possible to solve the whole system.
Start by solving the first 7 equations, and substitute the results into the remaining equations. simplify() and then solve the remaining two equations. After that do the appropriate back substitution.
There will be 24 solutions, some of which might possibly be spurious.
Note: the simplified version turns out to be two pairs of equations repeated, rather than 4 distinct equations.
syms E_e [3,1]
syms E_ee [3,3];
syms x1 x2 x3 y1 y2 y3 z1 z2 z3 u1 u2 u3 v1 v2 v3
eqns = [x1 + y1 + z1 + u1 + v1 == 5*E_e(1,1),...
x2 + y2 + z2 + u2 + v2 == 5*E_e(2,1),...
x3 + y3 + z3 + u3 + v3 == 5*E_e(3,1),...
x1*x1 + y1*y1 + z1*z1 + u1*u1 + v1*v1 == 5*E_ee(1,1),...
x1*x2 + y1*y2 + z1*z2 + u1*u2 + v1*v2 == 5*E_ee(1,2),...
x1*x3 + y1*y3 + z1*z3 + u1*u3 + v1*v3 == 5*E_ee(1,3),...
x2*x2 + y2*y2 + z2*z2 + u2*u2 + v2*v2 == 5*E_ee(2,2),...
x2*x3 + y2*y3 + z2*z3 + u2*u3 + v2*v3 == 5*E_ee(2,3),...
x3*x3 + y3*y3 + z3*z3 + u3*u3 + v3*v3 == 5*E_ee(3,3)];
vars = [x1,x2,x3,y1,y2,y3,z2,z3,z1];
X = lhs(eqns(:)) - rhs(eqns(:));
K = 7;
sol = solve(X(1:K), vars(1:K))
sol = struct with fields:
x1: [4x1 sym] x2: [4x1 sym] x3: [4x1 sym] y1: [4x1 sym] y2: [4x1 sym] y3: [4x1 sym] z2: [4x1 sym]
eqns2 = subs(X(K+1:end).', sol);
eqns2s = simplify(eqns2);
for KK = 1 : size(eqns2s,1)
sol4(KK,1) = solve(eqns2s(KK,:), vars(K+1:K+2));
end
Warning: Possibly spurious solutions.
Warning: Possibly spurious solutions.
sol4(1)
ans = struct with fields:
z3: [6x1 sym] z1: [6x1 sym]

Kategorien

Mehr zu Power and Energy Systems finden Sie in Help Center und File Exchange

Produkte


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by