# Least square curve fit in MATLAB for Alpha power law MOSFET model

Discussion in 'General Electronics Chat' started by ANALA, Aug 25, 2017.

Tags:
1. ### ANALANew Member

Joined:
Aug 14, 2017
Messages:
18
Likes:
0
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".

2. ### ci139Active Member

Joined:
Apr 12, 2012
Messages:
388
Likes:
34
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

Last edited: Aug 26, 2017
3. ### BobWActive Member

Joined:
Apr 28, 2010
Messages:
501
Likes:
52
Location:
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.

Joined:
Jan 12, 1997
Messages:
-
Likes:
0

5. ### ANALANew Member

Joined:
Aug 14, 2017
Messages:
18
Likes:
0

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...?

File size:
418 bytes
Views:
9

Joined:
Apr 28, 2010
Messages:
501
Likes:
52
Location: