Solving 3 Non-Linear Equations with Fsolve and FOR Loops

  • Thread starter Thread starter ethaniell
  • Start date Start date
  • Tags Tags
    For loops Loops
Click For Summary
The discussion centers on using the fsolve method to solve a system of three non-linear equations for three variables while varying a parameter from 1 to 5. The user is attempting to store the results in a matrix, where each row corresponds to one of the three variables and each column corresponds to the different values of the parameter. They are encountering errors when trying to store the results, indicating a potential issue with their implementation. The user seeks guidance on how to properly store the results and requests clarification on the specific error encountered during the process.
ethaniell
Messages
2
Reaction score
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
What is the error?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
28K
  • · Replies 2 ·
Replies
2
Views
2K