written for Matlab
(PC, Macintosh, or Unix)
This page describes a series of downloadable Matlab
interactive signal processing tools for x,y time-series
data. Documentation and examples of application are provided in
"A Pragmatic Introduction to Signal Processing",
available in HTML and PDF formats.
A complete list of my signal processing functions and scripts,
both interactive and command-driven, is given on functions.html. These scripts and
functions are downloaded about 1000 times per month on average and
have been used by thousands of scientists, engineers, researchers,
instructors, and students working in industry, environmental,
medical, engineering, earth science, space, military, financial,
agriculture, communications, and even music and linguistics. They
have been applied in many areas of
investigation and have been cited in over 130 published papers, theses, and
patents. Don't miss the amazing 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
versions; keep those emails coming. Note: all of the scripts and
functions described 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 and in Matlab
The interactive functions listed on this page run in the
Figure window and use a simple set of keystroke commands, rather
than on-screen buttons or menus or sliders, 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, and can be
Saved or Copied using the standard Matlab menus. 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 command window.
First time here?
Check out these animated Web demos of ipeak.m
and ipf.m. Or download these
Matlab demo functions 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. Note: Make sure you don't click on the
“Show Plot Tools” button in the toolbar above the figure;
that will disable normal program functioning. If you do;
close the Figure window and start again.
Author's 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).
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. There is
an animated demonstration.
These tools are the ones to use when (a) the quantities of
greatest interest are the peak positions and amplitudes of
the positive peaks in your signal, (b) the peaks have
distinct (even if noisy) maxima, and (c) 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,
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
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 many different shapes).
There two different
(1) peakfit.m, acommand line version, for Matlab and Octave, that
fits a predetermined number of peaks, and findpeaksfit.m,
which uses findpeaks.m to locate peaks as input for
the peakfit.m function (Octave users must install the
"optim_1.2.2" package). (2) Interactive
Peak Fitter, ipf.m, akeypress-operated interactive
version, for Matlab,
that allows you to pan and zoom through the signal to
pick the groups of peaks to fit.. Does
not work in Octave. There is an animated demonstration.
in Matlab, you can press a single keystroke to
instantly adjust the data range, change the peak shape,
number of peaks, baseline mode, or to re-calculate the fit
with different start or with a bootstrap subset of the
data. Super quick and easy.
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 (a) you need to measure
the peak positions, amplitudes, widths, and areas of the
positive peaks in your signal, (b) the peaks are highly
overlapped, (c) you want specific peaks in your signal
quantified, and (d) 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-reject (notch), comb
pass, and comb reject filters with variable,
frequency, width, and 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 4.1, December, 2014.
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. With a linear
response, absorbance can be converted to concentration
simply by multiplying by a constant factor.
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 Octave. TFitDemo.m 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).
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
concerning the interactive functions ipeak.m, isignal.m, and
Make sure you don't click on the “Show Plot Tools” button in
the toolbar above the figure; that will
disable normal program functioning. If you do; close the
Figure window and start again.
To facilitate transfer of settings from one of these
functions to another or to a command-line version,all
these functions use the Wkey
to print out the syntax of other related
functions, with the pan and zoom
settings and other numerical input arguments
specified, ready for you to Copy, Paste and edit
your own scripts or back into the command
window. For example, you can convert an curve
the command-line peakfit.m
or you can convert a peak finding
the command-line findpeaksG.m
Recent versions of
these three programs
use the Shift-Ctrl-S,
Background information on these and other signal processing
methods is available in:
" Your program
iPeak is like falling out of a tree and landing in a soft
couch complete with a book and a good reading light!"
script is simply phenomenal!
"...thanks a lot
for...your wonderful [peak
fitter] program. I use it on a regular basis...."
interactive peak fitter code for Matlab...has been very useful!"
"I have been using
iPeak ... (awesome program!!)."
Fitter...worked very well. In a word, it's perfect！"
a great tool!!"
"Your code is
download your very nice PeakFitter. It’s WONDERFUL!"
"You have great detailed instructions!"
"...how awesome your peakfitter is!"
imagine how MUCH we'll use this."
"...thank you for
taking the time to create these incredible
findpeaks.m and ipeaks.m ... [are] super
" ...thank you for
the scripts that you developed which are a very useful help for a lot of people
in science research."
"I got some really
good results using
[Peak Fitter] is perfect."
"I find these
routines and the information on your website immensely valuable."
"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 superbly."
"Your peak picking
algorithm is very helpful to
"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 Fitter programs."
"I found your Peak
Fitter program to be incredibly useful
for some work I am doing...."
"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".
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 my problem...."
"[It's] exactly 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
"Great code....Wonderfully documented!
"I am using your peakfitter in
Matlab and love it....worked like a charm"
"I've been having great success with ipf and
"...it really is a fine manual - your pdf document on
"Your Interactive Peak Fitter ... is very helpful."
"Your peak finding and fitting scripts ... turned out handy in analyzing my research
"I found your peakfit.m program and it is great - thank you very much for
"...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
"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...."
"... 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 instructive".
"...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 to me."
"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
"...it is going to help my research
"...your homepage about peak finding and measurement is amazing!"
"This is great. Thank you!"
"...thanks for the great tool! Saved me a lot of work."
"...iPeak ... is very useful."
"...your scripts are wonderful."
nice tutorial and Matlab functions that are extremely
useful in many fields of research."
"I used your peakfit MATLAB file
in a paper. I found it VERY useful
"I have been impressed by your MATLAB codes."
"Wow! ... this is exactly what I needed."
"You programs work very well and are very helpful to me. "
"...very convenient and
Copyright (c) 2014, 2015 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, sub-license, 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.