Signal Processing Tools

Free downloadable Matlab programs for scientists

Last updated May, 2012

Tom O'Haver
Professor Emeritus
Department of Chemistry and Biochemistry
University of Maryland at College Park
E-mail: toh@umd.edu

Programs written for Matlab (PC, Macintosh, or Unix)

Note: all of the programs 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 run in the Figure window and use a simple set of keystrokes commands, rather than a GUI (Graphic User Interface), in order to minimize overhead and to maximize processing speed.  Press K to see the list of keystroke commands for each program.  The Figure window can be resized as you wish, including maximized to full-screen to see the maximum detail in the signals.  See the unsolicited user comments below from actual users of these programs.

Peak Finding and Measurement 

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 upward zero-crossings for valleys) in the smoothed first derivative then determines the position, height, and width of each peak by least-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 seconds. 

This is available in three different versions:
(1) the basic command-line functions findpeaks.m and findvalleys.m.
(2) an interactive keypress-operated function (iPeak) for adjusting the peak detection criteria interactively to optimize for any particular peak type; and
(3) an older script using mouse-controlled sliders for interactive control. For Matlab version 6.5 (does not work in some newer Matlab versions).  You can also download it from the Matlab File Exchange.

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 command-line function.  Note: the latest version of the interactive peak finder (iPeak) can  perform iterative non-linear curve fitting, using the peakfit.m function described below, for the peaks that it finds; this is useful for highly overlapped or non-Gaussian peaks.


iSignal: Interactive Smoothing, Derivative, and Peak Sharpening 

iSignal is a Matlab function, written as a single self-contained m-file, for performing smoothing, differentiation, and peak sharpening (resolution enhancement), peak measurement and other useful  functions on time-series data. Using simple keystrokes, you can adjust the signal processing parameters continuously while observing the effect on your signal dynamically.  Click here to download the ZIP file "iSignal19.zip" that also includes some sample data for testing. You can also download it from the Matlab File Exchange. Version 1.95, May, 2012,  T. C. O'Haver (toh@umd.edu).

This is the tool to use when you want to explore your signals and to try smoothing, differentiation, and peak sharpening.  It's good for measuring things like peak-to-peak signal amplitude, standard deviation, and area under the curve of selected portions of your signal.  It's also good for measuring peak positions, heights, areas (one peak at a time) and for determining how smoothing, differentiation, and peak sharpening effect those measures. 



Interactive Peak Fitter

A Matlab peak fitting program for time-series signals, which uses a non-linear optimization algorithm to 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, Logistic, Pearson, and exponentially-broadened Gaussian peaks, and exponential pulse and sigmoid shapes (expandable to other shapes). There are three different versions:

(1) peakfit.m, a command line version,
(2) ipf.m, a keypress-operated interactive version, and
(3) an older version with mouse-controlled sliders (which requires Matlab 6.5).  

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 command-line function. Note: iterative non-linear curve fitting can also performed by the latest version of the interactive peak finder described above (iPeak).



iFilter: Interactive Fourier Filter

A Matlab implementation of a fourier filter function 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 create lowpass, highpass,bandpass, and band-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 the Matlab 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.


The TFit Method for quantitative absorption spectroscopy

Matlab implementation of a computational method for quantitative analysis by multiwavelength absorption spectroscopy, called the transmission-fitting or “TFit” method, based on fitting a model of the instrumentally-broadened transmission spectrum to the observed transmission data, rather than direct calculation of absorbance as 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 signal-to-noise ratio ratio rather than for optical ideality.

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 multi-wavelength data such as would be acquired on diode-array, Fourier transform, or automated scanning spectrometers, and (c) applies both to single-component and multi-component mixture analysis.

Click here to download a self-contained demo m-file that works in recent versions of Matlab. Version 2.1, November 2011.





iPower: Interactive Power Spectrum Demo

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 pre-set 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 File Exchange. T. C. O'Haver (toh@umd.edu), version 2, October 2011




Diffraction Grating Demos


A set of keyboard-controlled interactive demonstration modules, written as self-contained 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. 

Press K to see a list of all the keyboard commands. Tested in Matlab version 7.8 (R2009a).

Click here to download ZIP file.  You can also download it from the Matlab File Exchange. T. C. O'Haver (toh@umd.edu), version 2, November 2011

Click here to view larger figure

Background information on these and other signal procssing operations is available in:

A Basic Introduction to Signal Processing in Chemical Analysis

An illustrated essay available in Web, OpenOffice, Word , and PDF  format




Unsolicited Comments from Users

"Great code....Wonderfully documented!"

"I am using your peakfitter in Matlab and love it....worked like a charm"

"Your Interactive Peak Fitter ... is very helpful."

"Your peak finding and fitting scripts ... turned out handy in analyzing my research data."

"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...."

"Wonderful program."

"This program is fantastic."

"...incredibly useful...."

"... 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 colleagues".

"Thank you for your valuable website & code."

"...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."



First edition created in 2006. Last updated January, 2012. 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 toh@umd.edu. Number of unique visits to this website since May 17, 2008: