Solving 3 Non-Linear Equations with Fsolve and FOR Loops

  • Thread starter Thread starter ethaniell
  • Start date Start date
  • Tags Tags
    For loops Loops
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 5K views
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