Trying to solve 4 equation with 4 unknowns

157 visualizzazioni (ultimi 30 giorni)
Hello,
I am trying to solve this problem:
2a + 1b + 0c + 6d = 64
5a + 2b + 0c + 0d = 37
0a + 7b + 2c + 2d = 66
0a + 0b + 8c + 9d = 104
So I wrote this code:
clear;
clc;
equation1=64-2*a-b-6*d;
equation2=37-5*a-2*b;
equation3=66-7*b-2*c-2*d;
equation4=104-8*c-9*d;
sol=solve(equation1,equation2,equation3,equation4);
But it gives Undefined function or variable 'a' in line 3. I know I am missing something very obvious but I cannot find it. Could you help me?
Thank you.
  3 Commenti
Yashas Kumar G B
Yashas Kumar G B il 10 Ott 2020
It's easier than all discription which can easily understood by students . By seeing that we can get general syntax of problem of such typee
Tamara
Tamara il 2 Ago 2022
x + y + z + w = 10.3 2x - 7y + z - w = -1.5 -X - 3y - z + w = -6.9 3x + z - w = 2.4

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 10 Ott 2015
syms a b c d
equation1=64-2*a-b-6*d;
equation2=37-5*a-2*b;
equation3=66-7*b-2*c-2*d;
equation4=104-8*c-9*d;
sol=solve(equation1,equation2,equation3,equation4);
  3 Commenti
Walter Roberson
Walter Roberson il 10 Ott 2015
Is that a problem? You asked for a symbolic solution and you received a symbolic solution. You can look at the individual solutions with, for example,
sol.a
omercan demirel
omercan demirel il 10 Ott 2015
It worked. Thank you so much.
Also answers are: 5,6,4,8

Accedi per commentare.

Più risposte (1)

Liang Wei Teo
Liang Wei Teo il 10 Ott 2015
you can try changing everything to matrix and solve it using Ax=b

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by