From: Francesco on
I'm using the following code to compute the King's Law coefficient (hot-wire probe calibration law).

<<
start = [1;0.5;0.4];

options = fitoptions('Method','NonlinearLeastSquares','Display','iter','TolFun',10^-10,'TolX',10^-10,'StartPoint',start);

f = fittype('sqrt(A+B*x^n)');

res1 = fit(U,E_corr_w1,f,options)
>>

The problem is that (after successfully using the code for a while), now the following error pops up:

??? Complex value computed by model function.

Error in ==> fit at 437
errstr = handleerr( errid, errmsg, suppresserr );

while if using the 'cftool' with the same data set, graphically computing the coefficients everything works fine!!

I can't really see where's the problem.

Thanks in advance for any help.

Best regards.
From: us on
"Francesco " <francesco.baldani(a)rma.ac.be> wrote in message <i0hpg1$5ai$1(a)fred.mathworks.com>...
> I'm using the following code to compute the King's Law coefficient (hot-wire probe calibration law).
>
> <<
> start = [1;0.5;0.4];
>
> options = fitoptions('Method','NonlinearLeastSquares','Display','iter','TolFun',10^-10,'TolX',10^-10,'StartPoint',start);
>
> f = fittype('sqrt(A+B*x^n)');
>
> res1 = fit(U,E_corr_w1,f,options)
> >>
>
> The problem is that (after successfully using the code for a while), now the following error pops up:
>
> ??? Complex value computed by model function.
>
> Error in ==> fit at 437
> errstr = handleerr( errid, errmsg, suppresserr );
>
> while if using the 'cftool' with the same data set, graphically computing the coefficients everything works fine!!
>
> I can't really see where's the problem.
>
> Thanks in advance for any help.
>
> Best regards.

aree you sure you're using the very same options in both cases(?)...

us
From: Francesco on
if the default values for "Lower" and "Upper" (limits vectors) are -inf and inf then yes. Since I'm using also the same start values....



"us " <us(a)neurol.unizh.ch> wrote in message <i0hsjc$iju$1(a)fred.mathworks.com>...
> "Francesco " <francesco.baldani(a)rma.ac.be> wrote in message <i0hpg1$5ai$1(a)fred.mathworks.com>...
> > I'm using the following code to compute the King's Law coefficient (hot-wire probe calibration law).
> >
> > <<
> > start = [1;0.5;0.4];
> >
> > options = fitoptions('Method','NonlinearLeastSquares','Display','iter','TolFun',10^-10,'TolX',10^-10,'StartPoint',start);
> >
> > f = fittype('sqrt(A+B*x^n)');
> >
> > res1 = fit(U,E_corr_w1,f,options)
> > >>
> >
> > The problem is that (after successfully using the code for a while), now the following error pops up:
> >
> > ??? Complex value computed by model function.
> >
> > Error in ==> fit at 437
> > errstr = handleerr( errid, errmsg, suppresserr );
> >
> > while if using the 'cftool' with the same data set, graphically computing the coefficients everything works fine!!
> >
> > I can't really see where's the problem.
> >
> > Thanks in advance for any help.
> >
> > Best regards.
>
> aree you sure you're using the very same options in both cases(?)...
>
> us
From: Francesco on
PROBLEM SOLVED

up = [inf;inf;inf];
low = [-inf;-inf;-inf];

options = fitoptions('Method','NonlinearLeastSquares','Upper',up,'Lower',low,'Display','iter','TolFun',10^-10,'TolX',10^-10,'StartPoint',start);

I added upper and lower limits and set them to +inf and -inf respectively and it works...

Anyway I can't see why it was working before without specifying them and then it suddenly started giving troubles...

thanks.

"Francesco " <francesco.baldani(a)rma.ac.be> wrote in message <i0hu60$q74$1(a)fred.mathworks.com>...
> if the default values for "Lower" and "Upper" (limits vectors) are -inf and inf then yes. Since I'm using also the same start values....
>
>
>
> "us " <us(a)neurol.unizh.ch> wrote in message <i0hsjc$iju$1(a)fred.mathworks.com>...
> > "Francesco " <francesco.baldani(a)rma.ac.be> wrote in message <i0hpg1$5ai$1(a)fred.mathworks.com>...
> > > I'm using the following code to compute the King's Law coefficient (hot-wire probe calibration law).
> > >
> > > <<
> > > start = [1;0.5;0.4];
> > >
> > > options = fitoptions('Method','NonlinearLeastSquares','Display','iter','TolFun',10^-10,'TolX',10^-10,'StartPoint',start);
> > >
> > > f = fittype('sqrt(A+B*x^n)');
> > >
> > > res1 = fit(U,E_corr_w1,f,options)
> > > >>
> > >
> > > The problem is that (after successfully using the code for a while), now the following error pops up:
> > >
> > > ??? Complex value computed by model function.
> > >
> > > Error in ==> fit at 437
> > > errstr = handleerr( errid, errmsg, suppresserr );
> > >
> > > while if using the 'cftool' with the same data set, graphically computing the coefficients everything works fine!!
> > >
> > > I can't really see where's the problem.
> > >
> > > Thanks in advance for any help.
> > >
> > > Best regards.
> >
> > aree you sure you're using the very same options in both cases(?)...
> >
> > us