I want to use fzero to minimise a function of many variables, but with only one variable to be minimised. The other are just constants. In MATLAB I would do this by using something like :
x=fzero(@(x) myfun(x,a,b,c),x0)
where x is the variable to be minimised.
Unfortunately MathScript doesn't seem to accept the handle @, which leaves me stuck. Any ideas how to get round this problem?
I know that fzero can be used, and works fine with one variable. My question was regarding finding the zero for a function of more than one variable, but with only one to be changed i.e. not a system of equations.
Yes, and that has exactly the same problem, as the problem is with the use of @ rather than with fzero itself. However, I have worked out a solution using global variables instead, so that my function can be of just one variable with the other variables passed to it by making them global.
MathScript does not support the @ syntax, as you note. A workaround is to simply type the name of the function you wish to call. For example, x=fzero('myfun', x0);
Also, the function parameters currently only accept one argument. This is a limitation we are aware of. The global variable route is the workaround we recommend.
Grant M. Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments