From: Alison on
Hi all,

I'm using the following commands to fit a set of data and it worked perfectly. However when I increase the number of inputs for the function 'functionname' instead of just 'x' and 'y' it doesn't work anymore. The additional inputs for 'functionname' are not required to be fitted, they are just user defined values. I was wondering how I can define the values in 'functionname' while executing lsqcurvefit.

[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqcurvefit(@functionname,x101,x,y,[0.001 0.001 0.001 0.001 0.01],[50 50 50 10000 50],optimset('Display','iter','MaxIter',400,'MaxFunEvals',5000))

New function
function cout=functionname(x,y,par,rad,void,flow,feedc,height)

Old function
function cout=functionname(x,y)
From: John D'Errico on
"Alison" <ucbeata(a)ucl.ac.uk> wrote in message <hn5r2i$qpg$1(a)fred.mathworks.com>...
> Hi all,
>
> I'm using the following commands to fit a set of data and it worked perfectly. However when I increase the number of inputs for the function 'functionname' instead of just 'x' and 'y' it doesn't work anymore. The additional inputs for 'functionname' are not required to be fitted, they are just user defined values. I was wondering how I can define the values in 'functionname' while executing lsqcurvefit.
>
> [x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqcurvefit(@functionname,x101,x,y,[0.001 0.001 0.001 0.001 0.01],[50 50 50 10000 50],optimset('Display','iter','MaxIter',400,'MaxFunEvals',5000))
>
> New function
> function cout=functionname(x,y,par,rad,void,flow,feedc,height)
>
> Old function
> function cout=functionname(x,y)

New call:

[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqcurvefit(@(x,y) functionname(x,y,par,rad,void,flow,feedc,height),x101,x,y,[0.001 0.001 0.001 0.001 0.01],[50 50 50 10000 50],optimset('Display','iter','MaxIter',400,'MaxFunEvals',5000));

HTH,
John