multiple equations multiple variables solve command does not work
Show older comments
Hello, I'm trying to solve a set of equations but i know the unknown variables don't have exact answers, instead i need to find something else:
the variables are b , d , e
the equations are;
eqn1 = ((d-e)/1.8)-(e/3.3)-((e-b)/0.68)== 0
eqn2 = ((e-b)/0.68) == ((b-9)/4.7)+((b+3)/1.5)
eqn3 = ((9-d)/1.5) == ((d)/4.7) + ((d-e)/1.8)
I want to find;
d-e = ?
b isnt required to be known, but i would be happy if you showed me a way to find the answer with learning b and without needing b at all,
The main problem for me here is not to solve this easily, but to understand. I can solve using other internet calcualtors somehow but i want to learn how i can get a wanted value the next time i have x equations and y variables.
Thank you
1 Comment
Cem Taylan Meriç
on 2 Nov 2021
Accepted Answer
More Answers (1)
These equations are linear in the unknowns, so can be solved as follows:
% M*X = V where X = [b; d; e]
% and the coefficients are in M,
% with the constants in V
M = [1/0.68, 1/1.8, -(1/1.8 + 1/3.3 + 1/0.68);
-(1/0.68 + 1/4.7 -1/1.5), 0, 1/0.68;
0, -(1/1.5 + 1/4.7 -1/1.8), -1/1.8];
V = [0; -(9/4.7+3/1.5); -9/1.5];
X = M\V;
b = X(1); d = X(2); e = X(3);
disp(X)
disp(d-e)
3 Comments
Cem Taylan Meriç
on 2 Nov 2021
John D'Errico
on 2 Nov 2021
Edited: John D'Errico
on 2 Nov 2021
Alan, while what you have written is technically correct in how to solve the problem, it looks like you have some errors in the coefficients. And that means you got the wrong numerical solution. Just a minor error though. Since I used equationsToMatrix in my answer, it shows the differences clearly.
Alan Stevens
on 2 Nov 2021
Yes, I just eyeballed the numbers as I wrote the matrix and vector. I should have taken more care!
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

