Error solving three equations in three unknowns
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
syms Tan Man Lan eqns vars L av bv cv
Tan =- b - 2 == 0;
Man = c + 1 == 0;
Lan = a + b - 3*c - 1 == 0;
eqns = [Tan Man Lan];
vars = [a b c];
L = solve(eqns,vars,'ReturnConditions',true)
av=L.a
bv=L.b
cv=L.c
Error is Empty sym: 0-by-1
5 Kommentare
John D'Errico
am 25 Okt. 2020
First, I would point out you seem to think you need to define all of your variables.
syms Tan Man Lan eqns vars L av bv cv
Yet ALL of those variables were defined later.
In fact, the only variables in your code that you never defined as symbolic, were the ones you really need to define! That is, a,b,c all need to be created as symbolic variables, you you never did that.
Antworten (1)
John D'Errico
am 25 Okt. 2020
syms a b c
Tan = -b - 2 == 0;
Man = c + 1 == 0;
Lan = a + b - 3*c - 1 == 0;
[av,bv,cv] = solve(Tan,Man,Lan,a,b,c)
This is a linear system, so there is no need even to specify the returnconditions.
As you can see, the only thing I needed to define as symbolic were the variables a,b,c. Everything else is then derived from them.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Numbers and Precision finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!