Solving system of 3 non-linear equations.
84 ビュー (過去 30 日間)
古いコメントを表示
Hello, I'm trying to solve a system of equations using matlab.
The three variables are: xo2, xo, xar
I've entered the equations in as follows:
syms xo2 xo xar
eq1 = xo2 +xo +xar = 1
eq2 = 2*xo2 +xo -4*xar = 0
eq3 = 2.063E-4*xo2 = xo^2
Then, to solve the system for the variable xo I typed:
solve('eq1', 'eq2', 'eq3', xo)
and I get this message: Warning: Explicit solution could not be found.
What am I doing wrong? I'm fairly ceratain that this system is solvable.
is it because I am using symbolic algebra? For hte problem that I am solving, I dont need a general expression for the value, I just need a number.
2 件のコメント
YARA NABA
2019 年 3 月 10 日
移動済み: Dyuman Joshi
2024 年 4 月 4 日
syms x y z
eq1=exp(x)+sqrt(y)-z.^3-2
eq2=x.^2-y-z-5
eq3=x+exp(y-1)+z-7
sol=solve(eq1,eq2,eq3)
sol
how can i rewrite it
採用された回答
Oleg Komarov
2011 年 2 月 13 日
Rewrite as:
syms xo2 xo xar
eq1 = xo2 +xo +xar - 1;
eq2 = 2*xo2 +xo -4*xar;
eq3 = 2.063E-4*xo2 - xo^2;
sol = solve(eq1,eq2,eq3);
sol.xo
Oleg
3 件のコメント
Christopher Creutzig
2020 年 3 月 25 日
Adithya Valavi, did you try vpasolve?
It's usually a good idea to post a new problem in a new question, rather than adding a comment to something related.
その他の回答 (3 件)
Pierce Brady
2011 年 3 月 30 日
the output class will be syms, so try casting the answer to a double
class(ans)
double(ans)
class(ans)
Pier Giorgio Petrolini
2020 年 3 月 23 日
I hope it can be already helpfull...
syms x y z
eq1=exp(x)+sqrt(y)-z.^3-2
eq2=x.^2-y-z-5
eq3=x+exp(y-1)+z-7
eqs = [eq1, eq2, eq3]
[x,y,z]=vpasolve(eqs,[x,y,z])
% Reported results
x = -2.8;
y = 3.33;
z = -0.48;
1 件のコメント
Stephen Ofori
2023 年 1 月 13 日
This is also working, but the approximations makes it unsuitable for solutions where very small errors are required. If your work require minimal error then it is better to use the solve or fsolve.
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!