MATLAB Solving multivariable equation using Matlab

AI Thread Summary
To solve a multivariable equation in MATLAB, particularly one like f(x) = a*x + b*x^2 - c*x + d*(x^4 + e)^2, the appropriate function to use is 'solve' rather than 'fzero' or 'fsolve'. The issue arises when 'fzero' or 'fsolve' encounters an undetermined variable, leading to errors. By using 'solve', you can define the equation symbolically with 'syms x' and obtain the solution for x directly. This method effectively handles the complexity of the equation and provides the necessary output.
denisexx
Messages
1
Reaction score
0
Hi, I have a problem in solving a multivariable equation. This multivariable consists of several variable which is known and are insert as input intially. For example: f(x)= a*x+b*x^2+-c*x+d(x^4+e)^2, f(x)=0 and a,b,c,d,e are inputs. I wanted to get the answer x. I have tried to use fzero and fsovle, but Matlab seem to stop at the first equation when it cannot determine the value x. The error shows : X is undetermined variable or equation.

Ask: Am i right to use fzero/fsolve in this case to solve this equation?
 
Physics news on Phys.org
denisexx said:
Am i right to use fzero/fsolve in this case to solve this equation
No, use solve instead:
Code:
syms x;
eqn = a*x+b*x^2+-c*x+d*(x^4+e)^2;
s = solve(eqn,x);
s.x
 

Similar threads

Back
Top