For function like y = a*(x-b)^c, how can I use the least square curve fit feature to find out the coefficients a, b and c? But If i use the custom equation in cftool it reports " Complex value computed by model function, fitting cannot continue. Try using or tightening upper and lower bounds on coefficients".
it's about your input data - that is 2D vectors having 2D errors - if the errors are "bad" your fitting function won't cover the guessing of input errors
it might be possible to mod the algorithm to do that - which may need a recursive pass (trial error numerical approach) or solving very complicated analytical function - either way the task requires one to stay sharp on it e.g. you must ensure the right results are produced - e.g. the line that best fits your input points + MOSFET physics
I suggest that initially you modify the function to:
y = a*abs(x-b)^c
This will prevent the situation of trying to raise a negative value to a non-integer power. Once the fitting process comes up with approximate values for a, b and c, you can try removing the absolute value constraint.
I have attached my data and script..
predicted = @(a,x) a(1)*((x-a(2)).^a(3));
a0 = [?:?:?];
[ahat,resnorm,residual,exitflag,output,lambda,jacobian] = lsqcurvefit(predicted,a0,x,y);
May i know how to set the initial value of a0 inorder to obtain the fit and extract the co-efficients a1,a2,a3...?
I haven't used that matlab function, so I can't comment on your script. However, the fundamental problem is that your function is undefined at certain values of x. To help understand what I'm saying, try calculating the following:
(-3)^2.5
A negative number raised to a non-integer power has an undefined value. At least, it will not produce a real value. It will produce a complex value.
Therefore you must add some constraints. You have to make sure that one or both of the following conditions is true:
x-b>=0
or
c must be an integer
If you go with the first constraint, and taking into account that your first data point is x=0, then the value of b must always be negative. On the other hand if the exponent c is restricted to integer values, then b can take on any value positive or negative.