> The function that I declared looks like this:
> %%%%%%%%%%
> function F = myfun( y )
Presumably the function "TransformZetaAndEta" which you use in "fsolve" is a synonym for "myfun"?
> %y is the solution vector (xx zz zeta1 eta1)
Do you mean vector of independent variables? It isn't a solution yet...
> All variables are declared global and there are only four unknown variables.
It would be tidier to use nested functions instead of global variables:
http://www.mathworks.com/help/matlab/matlab_prog/nested-functions.html
Global variables have a tendency to result in exactly this kind of "untraceable" miscalculation, and nested functions would allow you to keep much more control over your variables:
- Fixed parameters can be simply included in the nested function.
- Independent variables are passed as function inputs.
- Results are passed as function outputs.
Globals are almost always a bad idea:
http://blogs.mathworks.com/videos/2010/03/08/top-10-matlab-code-practices-that-make-me-cry/
http://www.mathworks.com/matlabcentral/answers/51946-systematic-do-not-use-global-don-t-use-eval
Read the "fsolve" help page:
http://www.mathworks.com/help/optim/ug/fsolve.html
Get the outputs <exitflag> and <output>, these explain what "fsolve" is doing. If it is still not clear, make a new comment to this topic giving these output values, and someone might help you understand what they mean.
> %%%%%%%%%%
> function F = myfun( y )
Presumably the function "TransformZetaAndEta" which you use in "fsolve" is a synonym for "myfun"?
> %y is the solution vector (xx zz zeta1 eta1)
Do you mean vector of independent variables? It isn't a solution yet...
> All variables are declared global and there are only four unknown variables.
It would be tidier to use nested functions instead of global variables:
http://www.mathworks.com/help/matlab/matlab_prog/nested-functions.html
Global variables have a tendency to result in exactly this kind of "untraceable" miscalculation, and nested functions would allow you to keep much more control over your variables:
- Fixed parameters can be simply included in the nested function.
- Independent variables are passed as function inputs.
- Results are passed as function outputs.
Globals are almost always a bad idea:
http://blogs.mathworks.com/videos/2010/03/08/top-10-matlab-code-practices-that-make-me-cry/
http://www.mathworks.com/matlabcentral/answers/51946-systematic-do-not-use-global-don-t-use-eval
Read the "fsolve" help page:
http://www.mathworks.com/help/optim/ug/fsolve.html
Get the outputs <exitflag> and <output>, these explain what "fsolve" is doing. If it is still not clear, make a new comment to this topic giving these output values, and someone might help you understand what they mean.