How to solve 4 linear equations with 4 unknowns?
6 views (last 30 days)
Show older comments
Dane Kim
on 7 Apr 2019
Commented: Walter Roberson
on 27 Dec 2023
I got 4 linear equations with 4 unknown values to solve (R1,R2,R3,R4). I tried using matalb to get the answers and I'm having a difficult time. Can anyone help me solve this?
equ1='R1+R2 = 93.386 + (1.644*R3) - (9.9057*R4)'
equ2='R1+R2 = 73.02 + (2.263*R3) - (1.761*R4)'
equ3='R1+R2 = -141.48 + (12.62*R3) - (0.63*R4)'
equ4='R1+R2 = 31.725 + R3 + R4'
sol=solve(equ1,equ2,equ3,equ4)
0 Comments
Accepted Answer
Walter Roberson
on 7 Apr 2019
Edited: Walter Roberson
on 7 Apr 2019
A = [-1 -1 -1.644 8.938
-1 -1 -2.263 1.761
-1 -1 -12.62 0.63
-1 -1 -1 -1];
b = [93.386; 73.02; -141.48; 31.725];
A\b
However, it is obviously rank deficient. R1 and R2 are only ever used in the form R1+R2, so it is not possible to distinguish the two of them. You can rewrite all the R1+R2 as a temporary variable R1plusR2 and then the first three equations would be three equations in three variables, which would be enough to find all of the values, R1plusR2, R3, and R4. If you were then to substitute those results into the fourth equation, since it has no new forms of R1 or R2, then the left and right sides are completely determined, and the equation would either be false (inconsistent with the first 3) or true (consistent with the first 3) -- but if it were true then you still would not be able to figure out R1 separately from R2.
2 Comments
Walter Roberson
on 7 Apr 2019
syms R1 R2 R3 R4
equ1 = R1+R2 == 93.386 + (1.644*R3) - (9.9057*R4);
equ2 = R1+R2 == 73.02 + (2.263*R3) - (1.761*R4);
equ3 = R1+R2 == -141.48 + (12.62*R3) - (0.63*R4);
equ4 = R1+R2 == 31.725 + R3 + R4;
sol3 = solve([equ1,equ2,equ3], [R1, R3, R4])
check4 = subs(equ4, sol3);
if isAlways(check4)
fprintf('Consistent. Solution is R1 = %s, R3 = %s, R4 = %s, R2 = anything\n', sol3.R1, sol3.R3, sol3.R4);
else
fprintf('Inconsistent. R1 = %s, R3 = %s, R4 = %s, but final equation becomes %s\n', sol3.R1, sol3.R3, sol3.R4, check4);
end
More Answers (1)
youssef
on 27 Dec 2023
eq1= 5*x + 44*y + 420*z + 4256*t == 6004;
eq2= 44*x + 420*y + 4256*z + 44964*t == 62276;
eq3= 420*x + 4256*y + 44964*z + 488864*t == 669464;
eq4= 4256*x + 44964*y + 488864*z + 5422260*t == 7372916;
1 Comment
Walter Roberson
on 27 Dec 2023
syms x y z t
eq1= 5*x + 44*y + 420*z + 4256*t == 6004;
eq2= 44*x + 420*y + 4256*z + 44964*t == 62276;
eq3= 420*x + 4256*y + 44964*z + 488864*t == 669464;
eq4= 4256*x + 44964*y + 488864*z + 5422260*t == 7372916;
[A,B] = equationsToMatrix([eq1; eq2; eq3; eq4], [x y z t])
A\B
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

