From: Kev Del on
Hi,
I am trying to find an algorithm to make a power law fit with two scaling lines or regions. In summary the two axes of the function will be log-log and I am trying to find the two lines which can be used to approximate the function.

I would appreciate any advice on guidance on how to implement such an algorithm in matlab.

Thanks in advance,
Kev
From: Bruno Luong on
"Kev Del" <maedel(a)live.ie> wrote in message <hu5t6c$n6b$1(a)fred.mathworks.com>...
> Hi,
> I am trying to find an algorithm to make a power law fit with two scaling lines or regions. In summary the two axes of the function will be log-log and I am trying to find the two lines which can be used to approximate the function.
>
> I would appreciate any advice on guidance on how to implement such an algorithm in matlab.
>
> Thanks in advance,
> Kev

You might try this tool:
http://www.mathworks.com/matlabcentral/fileexchange/25872-free-knot-spline-approximation

p1 = 0.6;
p2 = -1.2;
a1 = 0.3;
a2 = 0.7;

% Power laws at 2 regions
x = logspace(-2,2);
y = a1*x.^p1+a2*x.^p2;

% Fit in log-log scale
options = struct('Annimation',1);
k = 2;
nknots = 5;
pp = BSFK(log(x),log(y),k,nknots,[],options);

% Do some work with pp to retrieve the power-law ...

% Bruno