Solving multivariable equation using Matlab

In summary, the individual has a problem solving a multivariable equation, with several known variables inputted. They attempted to use fzero and fsolve in Matlab, but encountered an error stating that x was an undetermined variable or equation. It is recommended to use the solve function instead in this case.
  • #1
denisexx
1
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
  • #2
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
 

1. How do I define and manipulate variables in Matlab?

In Matlab, variables are defined and manipulated using the assignment operator '=', followed by a value or expression. For example, to define the variable 'x' as 5, you would enter 'x = 5' in the command window. To manipulate variables, you can use any mathematical operator (+, -, *, /) or built-in functions.

2. What is the syntax for solving multivariable equations in Matlab?

The syntax for solving multivariable equations in Matlab is the same as solving single variable equations. You need to define all the variables involved in the equation and use the 'solve' function. For example, if you have the equation 2x + 3y = 9, you would enter 'solve(2*x + 3*y - 9)' in the command window.

3. Can I solve systems of equations using Matlab?

Yes, Matlab has a built-in function called 'fsolve' that can solve systems of equations. You need to define the equations and the variables involved, and the function will return the values of the variables that satisfy all the equations.

4. How do I plot the solution to a multivariable equation in Matlab?

To plot the solution to a multivariable equation in Matlab, you can use the 'ezplot' function. This function takes in an equation and the variables involved and plots the solution on a graph. For example, 'ezplot(x^2 + y^2 = 9)' will plot a circle with a radius of 3.

5. Can I solve multivariable equations with complex numbers in Matlab?

Yes, Matlab has built-in functions for solving equations with complex numbers. The 'solve' function can handle complex variables and equations, and the 'fsolve' function can also handle complex systems of equations. You can also use the 'roots' function to find the roots of a polynomial equation with complex coefficients.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
113
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
978
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Back
Top