MATLAB Answers

How to Solve sytem of 7 equations with 6 unknown variables? How to combine any two equations? equations and variables given belowRequest for help

2 views (last 30 days)
format short
syms eqn1 eqn2 eqn3 eqn4 eqn5 eqn6 eqn7 eqns sol p1sol p2sol p3sol p4sol p5sol p6sol p1 p2 p3 p4 p5 p6
eqn1 = -p1*0.00074+p2*30+ p5*2 + p6*0.2 == 0
eqn2 = p1*0.00062 - p2*30.00077 == 0;
eqn3 = p1*0.00012 +0.00031*p2 - p3*0.00012 == 0;
eqn4 = p2*0.00046 +p3*0.00012- p4*0.00063 == 0;
eqn5 = p4*0.0004 - p5*2 == 0;
eqn6 = p4*0.00023 - p6*0.2 == 0;
eqn7 = p1+p2+p3+p4+p5+p6==1;
% p1 to p6 above are 6 varaibles with 7 equations
% ? eqns = [eqn1, eqn2, eqn3, eqn4, eqn5, eqn7]
% ? sol = solve([eqns],[p1,p2,p3,p4,p5,p6]);

Accepted Answer

David Goodmanson
David Goodmanson on 28 Jun 2021
Hello Vijaya,
This is an overdetermined set of linear equations of the form M*x = b and can be solved in the least squares sense with the backslash function. The matrix M is (if I have not made a mistake)
M = [-0.00074 30 0 0 2 0.2
0.00062 -30.00077 0 0 0 0
0.00012 0.00031 -0.00012 0 0 0
0 0.00046 0.00012 -0.00063 0 0
0 0 0 0.0004 -2 0
0 0 0 0.00023 0 -0.2
1 1 1 1 1 1 ]
cond(M)
ans = 2.2943e+05
The condition number is large but not unreasonable. Then
b = [0 0 0 0 0 0 1]';
format short g
x = M\b
x =
0.45645
9.433e-06
0.45647
0.086954
1.7391e-05
9.9997e-05
concistency_check = M*x % compare with b
concistency_check =
1.2769e-17
7.3885e-18
-3.6135e-17
1.0916e-18
1.3783e-17
1.119e-18
1
This result is not so bad.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!