function [cp0,s] = minCDOMSlope(wl,spec)

opts = optimset('fminsearch');      
opts = optimset(opts,'MaxIter',400000); 
opts = optimset(opts,'MaxFunEvals',200000);   % usually 100*number of params
opts = optimset(opts,'TolFun',1e-9);

x0 = [1.0 0.8];

        % minimization routine a la Nelder Mead
        x = fminsearch(@least_square_ag, x0,opts,spec,wl); %lambda,lambda0

        cp0(1) = x(1);
        s(1) = x(2);
return     
    

function y = least_square_ag(x0,spec,l)

y=sum((spec-x0(1).*exp(-x0(2)*(l-440))).^2);
return
