Solving system of 3 non-linear equations.
Show older comments
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 Comments
YARA NABA
on 10 Mar 2019
Moved: Dyuman Joshi
on 4 Apr 2024
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
darova
on 10 Mar 2019
Moved: Dyuman Joshi
on 4 Apr 2024
What it is wrong with it?
Accepted Answer
More Answers (3)
Pierce Brady
on 30 Mar 2011
2 votes
the output class will be syms, so try casting the answer to a double
class(ans)
double(ans)
class(ans)
1 Comment
Tyler Tomlinson
on 12 Dec 2015
That was a huge help, thank you so much
Pier Giorgio Petrolini
on 23 Mar 2020
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 Comment
Stephen Ofori
on 13 Jan 2023
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.
Tushar
on 13 Feb 2011
2 Comments
Walter Roberson
on 14 Feb 2011
Use vpa() or double() to get the number in decimal format.
Tushar
on 14 Feb 2011
Categories
Find more on Numeric Solvers 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!