Solving 3 Non-Linear Equations with Fsolve and FOR Loops

In summary, The conversation is about using the fsolve method to solve for 3 variables in 3 non-linear equations. The speaker wants to know how the variables change when a parameter in the equations is changed from 1 to 5. They have tried storing the results in a matrix but it does not work with fsolve and always gives an error. They are seeking help on how to store the results successfully.
  • #1
ethaniell
2
0
Hi
I'm using the fsolve method to solve for 3 variables in 3 non-linear equations.
I would like to find out, how the 3 variables change, when I change a parameter in the 3 equations. Let's assume the parameter runs from 1 to 5 (1:1:5).

The iteration looks like this:
c=(1:5);
for i = 1:5
x = fsolve(@(x) myfun(x,c(i)),[1;1;1]);

end
I would like to store the results in a matrix, with the rows being each one of the three variables I solve for, and the columns being the variations in the parameter c.
I have tried the usual methods for storing, but it does not work with the fsolve, it always gives me an error.
Does anyone know how can I do it?
Thank you!
 
Physics news on Phys.org
  • #2
What is the error?
 

What is the purpose of using Fsolve and FOR loops to solve non-linear equations?

The purpose of using Fsolve and FOR loops is to numerically find solutions to non-linear equations that cannot be solved algebraically. These methods use iterative processes to approximate the solutions by repeatedly evaluating the equations with different input values.

How do Fsolve and FOR loops work together to solve non-linear equations?

Fsolve is a built-in function in many programming languages that uses a numerical root-finding algorithm, such as Newton's method, to find solutions to equations. FOR loops are used to repeatedly call the Fsolve function with different input values until the desired level of accuracy is achieved. This combination allows for efficient and accurate solutions to be found.

What is the advantage of using Fsolve and FOR loops over traditional algebraic methods for solving non-linear equations?

The advantage of using Fsolve and FOR loops is that they can find solutions to a wider range of non-linear equations, including those that are not easily solved algebraically. These methods also allow for more precision and accuracy in the solutions compared to traditional algebraic methods.

Are there any limitations to using Fsolve and FOR loops for solving non-linear equations?

Yes, there are some limitations to using Fsolve and FOR loops. These methods may not always find all solutions to an equation, and they may also converge to incorrect solutions if the initial input values are not chosen carefully. Additionally, these methods may be computationally intensive for more complex equations.

Can Fsolve and FOR loops be used to solve systems of non-linear equations?

Yes, Fsolve and FOR loops can be used to solve systems of non-linear equations. The equations can be written in vector form and the Fsolve function can be called for each element in the vector. FOR loops can then be used to iterate through different input values until a solution is found for all equations in the system.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Programming and Computer Science
Replies
1
Views
666
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Thermodynamics
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
8K
  • Beyond the Standard Models
Replies
6
Views
363
  • Electrical Engineering
2
Replies
38
Views
1K
Back
Top