Department of Chemistry and Biochemistry
University of Maryland at College Park
Have a question? E-mail: firstname.lastname@example.org
written for Matlab
(PC, Macintosh, or Unix)
Note: all of the
scripts below are written as self-contained Matlab functions
(m-files) and require no add-on toolboxes to run. They have been
developed and tested in Matlab 7.8 R2009a. All of the interactive
functions run in the Figure window and use a simple set of
keystroke commands, rather than a GUI (Graphic User Interface), in
order to reduce screen clutter, minimize overhead, and maximize
processing speed. Press K
to see the list of keystroke commands within each program. The
Figure window can be re-sized as you wish, including maximized to
full-screen to see the maximum detail in the signals. My goal is
to make these programs very easy to get working, with flexible
input syntax, built-in help, extensive online documentation, and
many simple examples that you can copy and paste into your Matlab
These scripts are downloaded about 1000 times per month on average
and have been used by thousands of scientists, engineers,
researchers, instructors, and students from over 60 countries.
They have been applied in many areas
of investigation and have been cited in dozens of published papers. See the unsolicited user comments below from
actual users of these programs. User comments and suggestions have
often resulted in changes and new features being added to the
latest version; keep those emails coming.
First time here? Download
these Matlab demos that compare iPeak.m with Peakfit.m for
signals with a few peaks and signals with
many peaks and that shows how to adjust
iPeak to detect broad or narrow peaks.
These are self-contained demos that include all required Matlab
functions. Just place them in your path and click Run or type their name at the
command prompt. Or you can download all these demos together in idemos.zip.
appreciation: I wish to express my thanks and
appreciation for all those who have made useful suggestions,
corrected errors, and who have sent me data from their work to
test my programs on. These contributions have really helped
to correct bugs and to expand the capabilities of my programs.
Matlab routines for locating and measuring the
peaks (or valleys) in noisy time-series data sets. It
detects peaks by looking for downward zero-crossings (or
for valleys) in thesmoothed
first derivative then determines the position,
height, and width of each peak byleast-squares
curve-fitting of the raw data near the detected
peaks. (This is useful primarily for signals that have
several data points in each peak, not for spikes that
have only one or two points). It can find and
measure 1000 peaks in a 1,000,000 point signal in 8
There are both command-line and interactive versions:
(1) a set of command-line functions for Matlab and Octave,
for finding peaks in signals and measuring their
positions, heights, widths, and areas by least-squares
curve-fitting, especially useful as modules to use in
your own custom scripts and functions to automate data
processing. (2) a Matlab-only interactivekeypress-operated function
adjusting the peak detection criteria interactively to
optimize peak detection and measurement, for Matlab.
These tools are the ones to use when (1) the quantities of
greatest interest are the peak positions and amplitudes of
the positive peaks in your signal, (2) the peaks have
distinct (even if noisy) maxima, and (3) when you want all
the peaks numbered and quantified in one
operation. You can use the interactive iPeak function to
determine the ideal input arguments for the findpeaks.m and findpeaksfit.m
command-line functions. Note: the
latest version of iPeak can perform iterative
non-linear curve fitting on the peaks that it finds, using
the built-in peakfit.m
function (described below); this is useful for highly
overlapped or non-Gaussian peaks. For some demos comparing
this to peakfit.m, download idemos.zip.
This is the tool to use when you want to explore and
clean up your signals and to try smoothing,
differentiation, and peak sharpening. It measures
things like peak-to-peak signal amplitude, standard
deviation, frequency spectra, and the area under the curve
of selected portions of your signal. It's also good
for quickly measuring
peak positions, heights, areas (one peak at a time)
and for determining how smoothing, differentiation, and
peak sharpening effect the signal and its frequency
spectrum. It can also pre-process signals to re-sample
them by interpolation, and reduce or remove artifacts such
as spikes (with the median filter) and steps (with a
Peak fitting programs for time-series
signals, which use anon-linear
optimization algorithmto decompose
a complex overlapping-peak signal into its component
parts. The objective is to determine whether your signal
can be represented as the sum of fundamental underlying
peaks shapes. Accepts signals of any length, including
those with non-integer and non-uniform x-values. Fits
groups of peaks of Gaussian, Lorentzian, Voigt,
Logistic, Pearson, exponentially-broadened Gaussian and Lorentzian, and exponential pulse and
sigmoid shapes (expandable to other shapes). There two different versions:
The difference between them is that peakfit.m
are completely controlled by command-line input arguments
and returns its information via command-line output
arguments; ipf.m allows interactive control via
keypress commands. Otherwise they have the same
curve-fitting capabilities. You can also
download a ZIP file containing peakfit.m,
ipf.m, Demoipf.m, some sample data for
testing, and a test script (testpeakfit.m)
that runs all the
examples sequentially to test for proper
These tools are the ones to use when (1) you need to measure
the peak positions, amplitudes, widths, and areas of the
positive peaks in your signal, (2) the peaks are highly
overlapped, (3) you want specific peaks in your signal
quantified, and (4) your peaks are approximately Gaussian,
Lorentzian, Pearson, Logistic, or exponentially-
broadened Gaussian. You can use the interactive ifp.m function to
determine the ideal input arguments for the peakfit.m and
command-line function. Note: iterative non-linear curve
fitting can also performed by the latest version of the
interactive peak finder
described above (iPeak). For some demos comparing peakfit.m
to iPeak.m, download idemos.zip.
iFilter is a Matlab implementation of aFourier
for time-series signals, including interactive versions
that allow you to adjust the filter parameters
continuously while observing the effect on your signal
dynamically. By adjusting the parameters, you can createlowpass,highpass, bandpass, andband-stop(notch)
filters with variable cut-off rate. The x-axis is labeled
for time-based signals, where the independent variable is
time in seconds, but the program can be used with any
frequency axis (e.g. spacial frequency, etc).Click here to view or download iFilter.m
You can also download it from theMatlab File Exchange.
Version 3, October 2011.
This is the tool to use when you want to explore the
frequency components of your signals and to design a custom
filter that will optimize your signals.
Matlab implementation of a
computational method for quantitative analysis by
multiwavelength absorption spectroscopy, called the
transmission-fitting or “TFit” method, based on measuring
the underlying absorbance byfitting a modelof the
instrumentally-broadened transmission spectrum to the
observed transmission data, rather than by direct
calculation of absorbance as simply log10(Izero/I).
Advantages of the TFit method compared to conventional
methods are: (a) wider dynamic range; (b) greatly
(c) ability to operate under conditions that are
rather than for optical ideality.
Just like themultilinear regression
(classical least squares)methods
conventionally used in absorption spectroscopy, the Tfit
method (a) requires an accurate reference spectrum of
each analyte, (b) utilizes multiwavelength data such as
would be acquired on diode-array, Fourier transform, or
automated scanning spectrometers, and (c) applies both
to single-component andmulti-component mixtureanalysis.
is a command-line demo function for Matlab or
is an interactive demo m-file that works in recent
versions of Matlab. Version 2.1, November 2011.
Matlab keyboard-controlled interactive power spectrum
demonstrator, useful for teaching and learning about the
power spectra of different types of signals and the effect
of signal duration and sampling rate. Single keystrokes
allow you to select the type of signal (12 different preset
signals included), the total duration of the signal, the
sampling rate, and the global variables f1 and f2 which are
used in different ways in the different signals. If you know
some basic Matlab programming, you can even add your own
custom signal functions to this program. When the Enter key
is pressed, the signal (y) is sent to the Windows WAVE audio
device. Press K to see a list of all the keyboard commands.
Tested in Matlab version 7.8 (R2009a).
Click here to view or
download. You can also download it from the Matlab
Exchange. T. C. O'Haver (email@example.com), version 2,
A set of
keyboard-controlled interactive demonstration modules,
written as self-contained Matlab functions, that are useful
for learning and teaching the
gratings. Shows a working cross
of the geometry of a diffraction grating (a common
illustration in textbooks of optics, spectroscopy, and
analytical chemistry). Single keystrokes allow you to
control such variables as the angle of incidence, grating
ruling density, wavelength, and diffraction order. One module
shows how the operation of a
diffraction grating emerges naturally just by adding up a
bunch of sine waves, without any higher math at all.
Press K to see a
list of all the keyboard commands. Tested in Matlab version
to download ZIP file. You can also download it from
Exchange. T. C. O'Haver (firstname.lastname@example.org), version 2,
"...thank you for
taking the time to create these incredible tools."
findpeaks.m and ipeaks.m ... [are] super useful"
"I got some really
good results using Ipeak.
"I find these
routines and the information on your website immensely
"I recently found
your website and I’m really impressed, great work! "
"I have been using
your "findpeaks" routine (matlab version) and it is working
"Your peak picking
algorithm is very helpful to me."
"As far as I am
concerned your code is perfect..."
function is very powerful. I had test many data with success."
"I'm impressed at
the convenience of your Peak Fitter and Interactive Peak
"I found your Peak
Fitter program to be incredibly useful for some work I am
"I found your
Matlab functions for peak detection very useful for my
research. Thanks for making this resource available, it's been
of great help to me".
"Best fitter available for Matlab,
thanks for this wonderful work."
"I have to say thank you for the great work you
done with the peak finding methods for Matlab. It is really
"I've been using ipeak over the past few weeks and
this is a wonderful tool."
"These are very
good script(s)....The scripts are very useful to help to solve
what I needed....The
result looks really great!"
"I have been using your
interactive peak fitter Matlab tool for a few months now, and
I have to say that it’s a wonderfully powerful and easy to use
program. I have been recommending it to everyone who
asks for peak fitting programs".
"I am using your peakfitter in
Matlab and love it....worked like
"I've been having great success
with ipf and peakfit..."
"...it really is a fine manual - your
pdf document on curve fitting."
"Your Interactive Peak Fitter ... is very helpful."
"Your peak finding and fitting scripts ... turned out
handy in analyzing my research data."
"I found your peakfit.m program and it is great - thank
you very much for sharing it!"
"...the codes for finding peaks and mathematical fits to
noisy data...were very helpful for my experimental work."
"I appreciate all the work that must have gone into the
PeakFit matlab coding. I've been using it for a couple of
weeks, now, and it is becoming extremely useful."
"Thank you for your Matlab function findpeaks(). It is
quite literally EXACTLY what I was looking for and far better
than I could have hoped."
"Thank you so much for designing and creating MATLAB code
for scientists! It's such a great resource to have code on
MATLAB Central. I really appreciate your efforts."
"Thank you for making available your absolutely superb
Peakfinder software. It is a snap to use...."
program is fantastic."
"... thanks for all the spectroscopy MatLab scripts that you
have written and meticulously documented. Finding them has
saved me more than a few hours."
"...excellent piece of software...really useful and
"...I would like to express my thanks for making such a
wonderful tool for derivative spectroscopy, it has been much
help for me!
"...Interactive Fourier Filter is a great tool to help with
low-, high-, band-pass-, and band-stop filtering, and best of
all, you can view the effect of filtering parameters on your
time-series as you change them! " (reference)
" I have been using iSignal for the past day to analyze my data,
and it works GREAT!.... I am able to extract lots of information
from my spectra now.'
"...such a great analysis program....Thank you...for designing
such a wonderful program."
"...the tutorials on your website have been of tremendous help
"My data is quite noisy and yet your program is able to fit it
with a very low error."
"Your web site has helped me a lot to solve one problem, I will
send to you the paper after publishing, so you will see how much
important it was for me."
"Your [iSignal] function is very good to explore the smoothing
and differentiation filters, I'll recommend it to my new
"Thank you for your valuable website & code."
"...your homepage about peak finding and measurement is
"This is great. Thank you!"
"...thanks for the great tool!
Saved me a lot of work."
"...iPeak ... is very useful."
"...your scripts are wonderful."
Copyright (c) 2013, Thomas C. O'Haver
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
First edition created in 2006. Last updated
November, 2013. This website was created with SeaMonkey.
This site is a retirement project maintained by Prof. Tom O'Haver,
Professor Emeritus, Department of Chemistry and Biochemistry, The
University of Maryland at College Park. Comments, suggestions and
questions should be directed to Prof. O'Haver at email@example.com.
Number of unique visits to this website since May 17, 2008: