Introduction: If discrete time signal x/n] represents a sampled continuous-time signal, then we
would like manner in which to produce from x[n] an output sequence y[n] that samples the derivative of
the continuous- time signal. Believe not. this task is not trivial for many signals. In particular, most real
signals are acquired in the presence of noise and sampled well above the Nyquist rate. An "ideal' discrete-
time differentiator filter has frequency response of X(eiw) jw. Thus, (x(eia) -w, or the frequency
response magnitude grows linearly with frequency. Thus, an ideal derivative will accentuate the high
frequency information. However, many systems are sampled at or (well) above the Nyquist rate-thus the
high frequency portion of the spectrum is dominated by noise. Hence, noise can dominate the output of a
simple differentiator, such as first difference Thus,several techniques have been developed for taking the
derivative of real signals Most cascade some approximation to the ideal frequency response with lowpass
filter. The first stage differentiates the signal. but also accentuates the high-frequency noise. The second
stage then attenuates the noise.
As an example, consider the exponentially decaying sinusoid shown above left. Its analytic
derivative is shown above right. In practice, most such signals are measured in the presence of some amount
of noise. So, below left shows the signal with small amount of noise added (white Gaussian noise with
standard deviation of 0.01). Next below right shows derivative estimate of this noisy signal using the first
backward difference method: where At is the sampling period. In this figure, the
magenta line is the true (analytic) derivative and the blue line is the estimate. Clearly, the estimated
derivative is quite notsy
The figure below left shows the spectrum of the noise-free signal (magenta) and of the noise (blue). The
signal- to-noise ratio is quite high at the low frequencies, but near value of 1 (0 dB) at high frequencies
The poor performance of the first backward difference as derivative estimate seems to be associated with
its high gain at high frequencies. One manner in which to resolve this issue is to cascade lowpass filter
after the first difference. The figure below right shows the output of this cascade. using zero-phase
lowpass filter whose cutoff frequency is 0.1 times the Nyquist frequency. Again, both the analytic derivative
(magenta) and estimate (blue) are shown. In this case, an excellent derivative estimate results
The Problem: Using this cascade of filters for derivative estimate, the optimal frequency location of the
lowpass filter and the filter order depend on the character of the input signal x[n]. Hence, this project is
formed bv studying methods of taking signal derivatives. One would likely start by selecting signal model
(always include signal with some noise). Sinusoids are likely not the best selection for signal, as they
analytic forms might be more appropriate for testing. Using an analytic model of the input signal, its "truth"
derivative can be determined analytically. Then, noise can be added to the signal, its derivative taken via
DSP. and finally compared to truth derivative. This process can be repeated while systematically varying
the filter cut-off frequency and the filter order of lowpass filter.
Some variations on this theme might include:
Different techniques for mimicking an "ideal" derivative, including backward difference, forward
difference and central difference,
Lowpass filtering with FIR vs. IIR filters,
Directly designing one filter that has a derivative characteristic at low frequencies, but lowpass
Time-domain curve fitting to produce the derivative:
o To find the derivative at one time location, fit smooth curve (polynomial, spline, etc.) to
several points in the neighborhood of the time location. Then, differentiate the smooth curve
analytically and evaluate at the time location. This process gives an estimate of the derivative
at that time. Now proceed to the next time and repeat etc. [See for example the discussion
of Savitsky Golay filters described in the book "Numerical Recipes in C"
Causal vs. n-causal (zero-phase) derivative estimates. In general, non-causal estimates tend to be
better for derivative estimates.
Your goal on this project is to select simulation signal model. with known derivative(s), and investigate
the performance of various methods for estimating derivatives. Your methods need not be able to be
implemented in real time, thus non-causal algorithms may be compared. As much as possible, you want
to answer the question as to how YOU would estimate a derivative, given particular signal model
Note that general solution likely depends on the signal model-s you should restrict your conclusions
to the model(s) you study
Primary MATI AB Code to Develop:
1) Write stand-alone MATLAB function for each signal simulation model that you develop. As
minimum, the function should return the noise-free signal and the noise realization.
random noise is rather commonly selected noise (see MATLAB function randn)
2) Write stand-alone MATLA AB function for each derivative estimation technique that you study (e.g.
first backward difference, first forward difference, central difference). Alternatively, you may write
single function then include an input variable that selects between the techniques.
3) Write stand-alone MATLAB function for lowpass filtering of the signal after difference has been
taken. Again, you may use input arguments to select the filter type (FIR, IIR and variations of them).
filter order, cut-off location, etc.
4) Write any other functions that are needed to perform analysis of your derivative estimate, as
explained below in Analysis. For example. you will be asked to evaluate the performance of each
estimated derivative. One nice measure is the mean squared error between the true (analytic
derivative) and your estimated derivative. When assessing this error, you most likely want to ignore
those samples in the start-up transient(s) (head and, sometimes, tail) of your filters
For this project, the analysis will be described rather loosely Your overall goal is to investigate the
performance of various methods for estimating derivatives. You want to recommend how someone
might do so, based on the characteristics of their signal
At minimum, implement at least two of the simple difference techniques (forward, backward,
central) in cascade with lowpass filter. At minimum. investigate at least one FIR and one IIR
style filter. So, there are four minimum combinations. For each. determine the performance of the
technique as function of model order and lowpass filter cutoff frequency. If possible, present the
performance of order -cutoff performance for each combination via 3D plot.
Additional analysis, if desired, can investigate any of many possible variants, including: different
signal models, different lowpass filter design methods, causal vs. phase non-causal processing,
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.
%Clearing the screen and workspace, closing all windows
%Generating linear chirp signal. The chirp is sampled at 200 Hz for 5
%seconds. The instantaneous frequency is 0 at t = 0 and reaches 20 Hz
%at T = 5 second.
fs = 200;
T = 5;
f0 = 0;
f1 = 10;
%Function for creating the signal and its analytical derivative
%Input: fs-Sampling rate, T-Duration in seconds, f0-Starting
%frequency, f1-Final frequency
%Output: y-Signal, yder-Signal analytical derivative, t-time vector
[y, yder, t] = signal(fs, T, f0, f1);
%Plotting chirp signal
axis([0 T -2 2]);...