Have a question? Email: toh@umd.edu
or join our group on Facebook
This page describes a series of downloadable Matlab
interactive signal processing tools for x,y timeseries data.
Technical background, documentation, and examples of application
are provided in "A Pragmatic Introduction to Signal
Processing", available in HTML and
PDF formats.
There are two type of interactive functions
described here: keystroke
operated and Live
Scripts.
The interactive functions listed in this section run in the Figure window and use a simple set of single keystroke commands, rather than onscreen buttons or menus or sliders, in order to reduce screen clutter, minimize overhead, maximize processing speed, and allow you to explore data and try out various approaches easily and quickly. Press K to see the list of keystroke commands within each program. The Figure window can be resized as you wish, including maximized to fullscreen or stretched over a twoscreen setup to see the maximum detail in the signals, and can be Saved in various formats, Copy/Pasted, or Printed, using the standard Matlab menus. My goal is to make these programs very easy to get working, with flexible input syntax, builtin help, extensive online documentation, and many simple examples that you can copy and paste into your Matlab command window. Note: all of the functions described below are written as selfcontained Matlab functions (mfiles) and require no addon toolboxes to run, but the scripts often call functions that must be downloaded and placed in the Matlab path. These interactive programs will even work if you run Matlab in a web browser, as shown on the right, (just click on the figure window before using the keypress functions), but unfortunately the interactive features do not work in Matlab Mobile on iPads and iPhones. If you use Octave instead of Matlab, you must use the separate Octave versions of these programs (indicated by "octave" added to the file names).
A complete catalog of over 200 of my signal processing functions and demonstration scripts, both interactive and commanddriven, are listed and described on functions.html. These scripts and functions are downloaded 5001000 times per month on average, both from my web site and from the Mathworks File Exchange, and they 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 360 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 (see Matlab File Exchange "Pick of the Week"); keep those emails and messages coming.
Peak Finding and MeasurementMatlab routines for locating and measuring the peaks (or valleys) in noisy timeseries data sets. It detects peaks by looking for downward zerocrossings (or upward zerocrossings for valleys) in the smoothed first derivative then determines the position, height, and width of each peak by leastsquares curvefitting 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 commandline and interactive versions: (1) a set of commandline functions for Matlab and Octave,
for finding peaks in signals and measuring
their positions, heights, widths, and areas
by leastsquares curvefitting, especially
useful as modules to use in your own custom
scripts and functions to automate data
processing. These are listed here, each
linked to its description:
findpeaksx,
findpeaksG,
findvalleys,
findpeaksL,
measurepeaks,
findpeaksG2d,
findpeaksb,
findpeaksb3,
findpeaksplot,
findpeaksplotL,
peakstats,
findpeaksE, findpeaksGSS,
findpeaksLSS,
findpeaksT,
findpeaksfit,
autofindpeaks
and autopeaks.
These can be used as
components in creating your own custom
scripts and functions. Don't
confuse with the "findpeaks"
function in the Signal
Processing Toolbox.
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 various findpeaks commandline
functions. Note: the latest version of iPeak
can perform iterative nonlinear curve fitting on the
peaks that it finds, using the builtin peakfit.m
function (described below); this is useful for highly
overlapped or nonGaussian peaks. For some demos,
download idemos.zip.
(2) The interactive keypressoperated function iPeak, or the Octave version, illustrated on the right displaying signals from a variety of sources. Using iPeak, you can pan and zoom, adjust each of the peak detection parameters individually and interactively to optimize peak detection and measurement, and much more. For Matlab only. There is an animated demonstration. 
iPeak


Interactive smoothing and differentiation Frequency spectrum mode 
Peak Fitters
Peak fitting programs for timeseries
signals, which use a nonlinear
optimization algorithm to decompose
a complex overlappingpeak 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 noninteger and nonuniform xvalues. Fits
groups of peaks of many different shapes).
There two different
versions: 



Hyperlinear quantitative absorption spectroscopyMatlab implementation of a computational method for quantitative analysis by multiwavelength absorption spectroscopy, called the transmissionfitting or "TFit" method, based on measuring the underlying absorbance by fitting a model of the instrumentallybroadened 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
improved calibration linearity;
(c) ability to operate under conditions that are
optimized for signaltonoise
ratio ratio
rather than for optical ideality. With a linear
response, absorbance can be converted to concentration
simply by multiplying by a constant factor. Just like the multilinear 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 diodearray, Fourier transform, or
automated scanning spectrometers, and (c) applies both
to singlecomponent and multicomponent mixture analysis. tfit.m is a commandline demo function for Matlab or Octave. TFitDemo.m is an interactive demo mfile that works in recent versions of Matlab. Version 2.1, November 2011. 

iPower: Interactive Power Spectrum DemoMatlab keyboardcontrolled 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.Click here to view or download. You can also download it from the Matlab File Exchange. Version 2, October 2011 

Diffraction
Grating Demos
A set of
keyboardcontrolled interactive demonstration modules,
written as selfcontained Matlab functions, that are
useful for learning
and teaching the principles of diffraction gratings. Shows a working cross
section
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.

(a) 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.
(b) To facilitate transfer of settings from one of these functions to another or to a commandline version,all these functions use the W key 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 into your own scripts or back into the command window. For example, you can convert an iSignal.m operation onto a commandline ProcessSignal.m call, or a curve fit in ipf.m into the commandline peakfit.m function, or a peak finding operation from ipeak.m into the commandline findpeaksG.m or findpeaksb.m or findpeaksb3.m functions. This provides a way to deal with signals that require different signal processing in different regions of their xaxis ranges, by allowing you to create a series of commandline functions for each local region that, when executed in sequence, quickly process each segment of the signal appropriately.
(c) Recent versions of these three programs use the ShiftCtrlS, ShiftCtrlF, and ShiftCtrlP keys to transfer the current signal between iSignal.m, ipf.m, and iPeak.m
The script has several interactive controls. The two sliders in lines 9 and 10 allow you to select which portion of the data range to process, from 0% to 100% of the total range of the data file. The SmoothType dropdown menu in line 13 selects the smoothing algorithm; each has one or more controls specific to that type in lines 16 to 30. The first choice is the recursive sliding average (fastsmooth.m) algorithm explained above. The smooth width and number of passes are controlled by the sliders in lines 16 and 17. Each The other controls are explained in the accompanying comment lines (in green). Fourier filtering, SavitskyGolay and wavelet denoising are topics that will be explained in other sections. The PlotBeforeAndAfter checkbox in line 3 gives you the option of plotting the original signal (in black) along with the processed signal (in red). The FrequencySpectra checkbox in line 4 allows you to show the frequency spectrum of the original and/or processed signals (see HarmonicAnalysis.html). Note: to view the graphic plots to the right of the code, as shown above, rightclick on the empty space on the right and select "Disable synchronous scrolling".
DeconvoluteData.mlx can
perform Fourier selfdeconvolution on you own data stored in
disk. Clicking the Open data file button in line 1
opens a file browser, allowing you to navigate to your data
file in .csv or .xlsx format. (The script assumes that your
x,y data are in the first two columns; you can change that in
lines 13 and 14). In the case shown here, the data file is a
portion of the IR spectrum of Heptene, 'HepteneTestData.csv',
shown as the 'file' variable in the workspace. The The startpc and endpc sliders
in lines 9 and 10 allow you to select which portion of the
data range to process, from 0% to 100% of the total range of
the data file.
The PeakShape dropdown menu in line 17 selects the convolution function shape (in this case, a GaussianLorentzian blend) and the PCGaussian slider in the next line allows selection of the percent Gaussian of that shape. The dw slider in line 21 controls the deconvolution halfwidth, the DA slider in line 23 controls the percent denominator addition. Smoothing, by Fourier filtering, is controlled by the FrequencyCutoff and CutOffRate in lines 25 and 27. All variables are accessible in the Matlab workspace; the final signal is 'syDA'.
Click the FrequencySpectra
check box in line 4 to view the frequency spectra. Click
the PlotAllSteps check box in line 5 to
view all the steps leading up the the final result.
To view the figures to the right as shown below,
rightclick on the righthand panel and select
"Disable synchronous scrolling".
Like the
other Live Scripts described above, PeakFittingTool.mlx
has a file browser button in line 1 and a pair of sliders in lines 4
and 5 for setting the desired segment to work on.
But before opening a file, it's a good idea to temporarily
deselect the "FitPeaks" checkbox in line 14, then
when you have set all the other controls, click it back on.
That way you will avoid waiting for unnecessary curve fit
operations until the appropriate settings are complete.
(Sometimes curve fitting operations can be slow and can take
several seconds in difficult cases). With FitPeaks switched off,
the program simply displays a plot of the
selected data file.
"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 ... and it is becoming extremely useful."
",,,your Matlab function findpeaks()...is quite literally EXACTLY what I was looking for and far better than I could have hoped."
"...MATLAB code for scientists! It's such a great resource to have.... I really appreciate your efforts."
"Thank you for making available your absolutely superb Peakfinder software. It is a snap to use...." "Wonderful program."
Copyright (c) 2014, 2021 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
conditions:
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.