Code covered by the BSD License  

Highlights from
AdvCurveFit

image thumbnail

AdvCurveFit

by

 

27 Aug 2004 (Updated )

Solve complex curve fit problem with parameter pooling & stratification by nonlinear least-squares.

PkBgErr(x,y,pk,bg)
function h = PkBgErr(x,y,pk,bg)
%PKBGERR returns function handle.

% Copyright 2004-2010 RBemis The MathWorks, Inc. 

h = @errFcn;
  function err = errFcn(param) %nested
    a = param(1:3);
    b = param(4:6);
    c = param(7:9);
    d = param(10);
    e = param(11);
    err = zeros(size(y));
    for i=1:3
      err(:,i) = pk(x,a(i),b(i),c(i)) + bg(x,d,e) - y(:,i);
    end %for loop
  end %nested function
end %main function

Contact us