User defined fit function does not find dependencies
Thu, 04/16/2020 - 09:49 am
In the curve fitting tool, I defined a New Fit Function like so:
if (x >= (x1-(b/2)) && x <= (x1+(b/2)))
f(x) = y0+A
f(x) = y0
When I execute the function, however, it doesn`t do the fit but says:
**** Singular matrix error during curve fitting ****
There may be no dependence on these parameters:
W_coef is b, W_coef is x1.
It is obvious from the data that it does depend on these coefficients, so I think it must be something else. Is this the correct way to define a fit function at all? Where is the mistake?
If it helps:
There is something wrong about the fit, also when I had written it a bit different:
if (x < (x1-(b/2))|x > (x1+(b/2)) )
f(x) = y0
elseif(x >= (x1-(b/2)) && x <= (x1+(b/2)))
f(x) = y0+A;
it said "The fitting function returned NaN for at least one X value.", which should not be the case. I added the "else" case then to make sure there is an f(x) for every case, but this just led to the above problem of not finding dependencies on fit coefficients.
Attached is the experiment.
Thank you for your help!