index previous next

Interactive Derivative

A Matlab routine for interactive differentiation of time-series signals, with sliders that allow you to adjust the derivative order, smooth width, and scale expansion continuously while observing the effect on your signal dynamically. Requires Matlab 6.5. Run InteractiveDerivativeTest to see how it works. Click here to download the ZIP file "InteractiveDerivative.zip" that also includes supporting functions, self-contained demos to show how it works. You can also download it from the Matlab File Exchange.

InteractiveDerivative.m

Click to view enlarged figure
Click to view enlarged figure
Interactive differentiation script for your own data, with sliders to control derivative order, smooth width, and scale expansion. Requires Matlab 6.5. To use it, place your signal in the global variables "x" and "signal" and then execute this m-file. Use the Order and Smooth sliders to change the derivative order and smooth width. Use the Scale slider to expand or contract the y-axis scale. The smoothed derivative is placed in global variable "derivative". The actual differentiation is performed by the function InteractiveDerivativeRedraw, which is called when the sliders are moved. If you wish, you can change the maximum range of the smooth width slider (MaxSmoothwidth in line 14) and the maximum range of the derivative order slider (MaxDerivativeOrder in line 15). You can also change the smoothing function by replacing "fastsbmooth" in InteractiveDerivativeRedraw with any other smoothing function. InteractiveDerivativeTest is a simple test of InteractiveDerivative; it generates a synthetic signal assigned to "signal", then calls InteractiveDerivative.

DerivativeDemo.m

Click to view enlarged figure
Click to view enlarged figure
Demonstration of the application of differentiation to the detection of peaks superimposed on a strong, variable background. Requires Matlab 6.5. Generates a signal peak, adds random noise and a variable background, then differentiates and smooths it, and measures the signal range and signal-to-noise ratio (SNR). Interactive sliders allow you to control the following variables:
Amp: The amplitude (peak height) of the signal peak.  
Default range: 0-3
Back1: The amplitude of the background.
Default range: 0 to 20
Back2: The position of the background.
Default range: -800 to +800
Noise: Random white noise added to the signal.
Default range: 0 - 0.5
Order: Derivative order. Default range: 0-4
Scale: Scale expansion of the y-axis.
Default range: 0.1 - 10.
Smooth: Width of the smoothing function, in data points.
Default range: 0 - 100
Resamp: Applies different random noise samples, to demonstrate
the low-frequency noise that remains after smoothing.

Video Demonstrations of DerivativeDemo.m

The first 13-second, 1.5 MByte video (SmoothDerivative2.wmv ) demonstrates the huge signal-to-noise ratio improvements that are possible when smoothing derivative signals, in this case a 4th derivative.

The second video, 17-second, 1.1 MByte, (DerivativeBackground2.wmv ) demonstrates the measurement of a weak peak buried in a strong sloping background. The amplitude (Amp) of the peak is varied between 0 and 0.14, but the background is so strong that the peak, located at x = 500, is hardly visible. Then the 4th derivative (Order=4) is computed and the scale expansion (Scale) is increased, with a smooth width (Smooth) of 88. Finally, the amplitude (Amp) of the peak is varied again, but now the changes in the signal are now quite noticable and easily measured.

ZIP file containing all of the above Interactive Derivative functions and demos.

Tom O'Haver
Professor Emeritus
Department of Chemistry and Biochemistry
The University of Maryland at College Park
toh@umd.edu
http://www.wam.umd.edu/~toh


index previous next

Number of unique visits since May 17, 2008:

counter
create hit