Code covered by the BSD License  

Highlights from
Interactive Peak Fitter, version 2.2

image thumbnail
from Interactive Peak Fitter, version 2.2 by Tom O'Haver
A peak fitting program for time-series signals.

norm(z-y');
function err = fitNewPeakShape(lambda,t,y)
% Replace "NewPeakShape" with the peak function of your choice.
%  T. C. O'Haver, 2006   
global c
A = zeros(length(t),round(length(lambda)/2));
for j = 1:length(lambda)/2,
    A(:,j) = NewPeakShape(t,lambda(2*j-1),lambda(2*j))';
end
c = A\y';
z = A*c;
err = norm(z-y');

Contact us at files@mathworks.com