Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Problem with "lsqnonlin" function in matlab
Replies: 6   Last Post: Sep 10, 2011 8:05 AM

 Messages: [ Previous | Next ]
 fsalehi Posts: 13 Registered: 8/30/11
Re: Problem with "lsqnonlin" function in matlab
Posted: Sep 10, 2011 8:05 AM

"Steve Grikschat" wrote in message <j45i2k\$d9\$1@newscl01ah.mathworks.com>...
> "fsalehi " <fsalehi@gmail.com> wrote in message <j3nb0t\$2ol\$1@newscl01ah.mathworks.com>...
> > spasmous <spasmous@gmail.com> wrote in message <d247a374-7fc4-4772-b19b-d800332e51cd@t30g2000prm.googlegroups.com>...
> > > On Aug 30, 12:34 am, "fsalehi " <fsal...@gmail.com> wrote:
> > > > I  have a problem with 'lsqnonlin' function in matlab. I used it to optimizing this function:
> > > >
> > > >     objfun = @(z) y - ( z(5).*exp(-z(1).*(t-z(7)).^2).*cos(2*pi.*z(2).*(t-z(7))+z(3)) + z(6).*exp(-z(1).*(t-z(8)).^2).*cos(2*pi.*z(2).*(t-z(8))+z(4)) );
> > > >
> > > > % y is my signal and I optimize a guassian pulse function for Model Base Estimation
> > > >
> > > > options = optimset(options, 'MaxFunEvals', 10000, 'TolX', 1e-3, 'TolFun', 1e-2, 'MaxIter', 800, 'LargeScale', 'on', 'LevenbergMarquardt', 'on', 'DiffMaxChange', 1e-7, 'DiffMinChange', 1e-10, 'Display', 'off', 'Diagnostics', 'off');
> > > >

> > >
> > > i would try Display 'iter' to see what is happening. TolFun seems kind
> > > of large and DiffMaxChange kind of small. Aslo I'm not sure
> > > LargeScale, LevMarq and bound constraints are all compatible either.

> >
> > I'm not sure too. but I dont know what setting I should use?

>
> Regarding the LargeScale and LevenbergMarquardt settings, lsqnonlin will run the LargeScale (a.k.a. trust-region-reflective) algorithm since the parameters are constrained by bounds. This is not an issue.
>
> I agree about the DiffMaxChange being too small. When your parameter (alpha) is on the scale of 1e13, then a difference of 1e-7 will be far too small to get an accurate finite-difference derivative estimate. What might be happening is that the derivative estimate for the first parameter may appear flat:
>

> >> (1e13+1e-7) - 1e13
> ans =
>
> 0
>
> Try scaling the alpha parameter to be the same scale as the other parameters. Unfortunately, DiffMaxChange and DiffMinChange are one-size fits all options so increasing DiffMaxChange to a larger value may negatively affect your other parameters.
>
> Regards,
> +Steve

Thank you Steve,