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.

ipfbackground(n,h)
function ipfbackground(n,h)
% Allows user to click graph to enter background points, 
% then computes fit and re-draws graph
% Tom O'Haver,  Version 1.2, October 17, 2006.

global x
global y
global xx
global yy
global NumPeaks
global Shape
global delta
global c
global FitResults
global start

% Acquire background points from user mouse clicks
subplot(2,1,1);xlabel('Click on the background to the LEFT the peak(s).')
[X1,Y1] = GINPUT(1);
subplot(2,1,1);xlabel('Now click on the background to the RIGHT the peak(s).')
[X2,Y2] = GINPUT(1);
n=length(xx);

% Create "start" for this number of peaks
yy=yy-((Y2-Y1)/(X2-X1)*(xx-X1)+Y1);


FitResults=FitAndPlot(xx,yy,NumPeaks,Shape,delta,start);

% axes(h);
h2=gca;

Contact us at files@mathworks.com