%This is the driver used to find the best fit power-law function
%Assumes ac-9 like data

cp=[1.50 1.40 1.26 1.22 1.16 1.11 0.95 0.92 0.85]; 
wl=[412 440 488 510 532 555 650 676 715];

%setting options for fmisearch
opts = optimset('fminsearch');      
opts = optimset(opts,'MaxIter',4000); 
opts = optimset(opts,'MaxFunEvals',2000);   % usually 100*number of params
opts = optimset(opts,'TolFun',1e-9);
%opts = optimset('LevenbergMarquardt','on');

%guess for paramters (amplitude at 532 and slope)
x0=[1.22, 1];

%minimization routine
x1 = fminsearch(@least_squares_cp,x0,opts,cp,wl)

%plot data and fit
plot(wl, cp, '.k', wl, x1(1)*(532./wl).^x1(2),'b')


