Storing fsolve results in a matrix across parameter iterations

1 reply · 5K views · last reply
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!