Solving multivariable equation using Matlab

  • Context: MATLAB 
  • Thread starter Thread starter denisexx
  • Start date Start date
  • Tags Tags
    Matlab Multivariable
Click For Summary
SUMMARY

The discussion centers on solving a multivariable equation in MATLAB, specifically using the functions fzero and fsolve. The user encountered an error indicating that the variable x was undetermined when attempting to solve the equation. The correct approach is to utilize the 'solve' function in MATLAB, which allows for symbolic computation. The recommended code snippet is: syms x; eqn = a*x+b*x^2+-c*x+d*(x^4+e)^2; s = solve(eqn,x); s.x.

PREREQUISITES
  • Understanding of MATLAB syntax and functions
  • Familiarity with symbolic mathematics in MATLAB
  • Knowledge of multivariable equations
  • Basic algebraic manipulation skills
NEXT STEPS
  • Learn about MATLAB's 'solve' function for symbolic equations
  • Explore the use of 'syms' for defining symbolic variables in MATLAB
  • Investigate error handling in MATLAB when solving equations
  • Study examples of multivariable equation solving in MATLAB documentation
USEFUL FOR

Mathematics students, engineers, and data scientists who need to solve complex multivariable equations using MATLAB.

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

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K