It does not work because L(1) = 0, so log(L(1)) = Inf,
and polyfit can't fit a line with an Inf point.
Try: polyfit(log(L(2:end)),log(S(2:end)),1) and it will work.
F
"Alireza Y." <bilgi_yk2@yahoo.com> wrote in message <hf5ab1$qs8$1@fred.mathworks.com>...
> Hello,
> I have two variables (vectors):
> L=[0 200 400 600 800 1000] %L:Length
> S=[0.002 0.001 0.003 0.001 0.002 0.01] %S:Slope
> and I have to calculate the coefficients Lambda(slope) and Gama(intercept) of a straight line by regression of my data on loglog graph.
> formula: lnS=GamaLambda*lnL;
> In cftool, axes are normal (not loglog). I also tried ployfit(x,y,n) in polyfit(log(L),log(S),1) way, but it didn't work and answer was NaN NaN.
> what code should i use for fitting a straight line(linear fitting) and calculation of Lambda and Gama.
> thaks in advance
