Suppose I have 10 equations and 10 unknowns. In the equations there are 10 constants that I don’t optimize, say C1,C2,…C10.
Is there a way to use Fsolve and Loops to solve my equations if I have 5 different sets of constants ( 5 times C1,C2,…C10) that satisfy my original 10 equations. Simply put, instead of rewriting my 10 equations and 10 unknowns… 5 times by hand, is there a way to loop inside the @myfun m-file I wrote to solve for my 10 unknowns?
Use anonymous functions, available in MATLAB since R14 I believe.
From fsolve help:
If FUN is parameterized, you can use anonymous functions to capture the problem-dependent parameters. Suppose you want to solve the system of nonlinear equations given in the function myfun, which is parameterized by its second argument c. Here myfun is an M-file function such as
function