From: Edvin on
Hello everyone,

So I'm using the interactive curve fitting tool to fit data to a custom function:
a * (b - (x-c)^(3/2))

The problem is that whenever x-c is negative, (x-c)^(3/2) becomes complex and so matlab is unable to compute the fit, giving an error message similar to the one in the title.

Is there any way I can ask matlab to bypass these complex value and just go on with the fit ? Obviously I can set constraints on c, but that is a bit tricky in the situation at hand and kind of defeats the purpose of fitting ... Thanks.

Best,
Edvin
From: James Allison on
Filter out all data that leads to complex data before you perform a fit.
Suppose I generate my dataset using lhsdesign:

d1 = lhsdesign(20,2);

The value of x-c is:

a = d1(:,1)-d1(:,2);

And I can create a new data set with (x-c)<0 filtered out:

d2 = d1(a>=0,:);

I hope this helps.

-James

Edvin wrote:
> Hello everyone,
> So I'm using the interactive curve fitting tool to fit data to a custom
> function: a * (b - (x-c)^(3/2))
>
> The problem is that whenever x-c is negative, (x-c)^(3/2) becomes
> complex and so matlab is unable to compute the fit, giving an error
> message similar to the one in the title.
> Is there any way I can ask matlab to bypass these complex value and just
> go on with the fit ? Obviously I can set constraints on c, but that is a
> bit tricky in the situation at hand and kind of defeats the purpose of
> fitting ... Thanks.
>
> Best, Edvin