# Signals, Spectra and Signal Processing

Name:__________________________________
Date Performed: _________________________

Rating:__________________________
Date Submitted: __________________

Signals, Spectra and Signal Processing
ANALYSIS OF DISCRETE-TIME SYSTEMS:
CONVOLUTION AND DIFFERENCE EQUATION
Activity No. 6
I. INTENDED LEARNING OUTCOMES
1. Use the MathScript RT module of LabVIEW to generate and plot elementary discrete-time signals.
2. Analyze implementation of discrete-time systems using the convolution sum and the difference
equation.
3. Use the convolution sum and the difference equation to implement discrete-time systems.
II. BACKGROUND INFORMATION
Discrete-time systems can be analyzed and implemented in two ways: using the convolution sum and
through a recursive algorithm that can be expressed in terms of a difference equation.
The convolution sum is implemented through four operations: folding a signal in time, shifting the folded
signal by a number of sample, multiplying the signals and summing up the product sequence. The
algorithm for computing the convolution sum y(n) of the signals x(n) and h(n) is

y(n) = x(n) ∗ h(n) =

x(k)h(n − k)

For a finite-duration signal, this implementation is effective. However, for signals with infinite duration, a
recursive algorithm may be more effective since it is computationally more efficient and requires less
memory.
Recursive systems are those systems that use memory elements to store all past results of the
computations, use it when needed, and updates itself when new values arrive. This implementation is more
practical when the system is characterized by an infinite impulse response.The impulse response of a
discrete-time system is the response of the system for a unit sample input. This impulse response
characterizes the system and is used to generate the response of the system for any arbitrary input,
through the convolution sum. Another important characterization of systems is the step response, which is
the output of the system for a step input.

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 1

Signals, Spectra and Signal Processing
Recursive systems are described by difference equations which have the general form
y(n) = −

a y(n − k) +

b x(n − k)

where the values a and b are the filter coefficients of y(n) (with a = 1) and x(n) respectively. The
number N is the order of the system.
In this activity, the MathScript module of LabVIEW will be used. The MathScript module of LabVIEW is
intended to increase compatibility with m-files, or programs created using MATLAB. Inside the MathScript
module, a source code with syntax and semantics similar to MATLAB is used. Thus, MATLAB programs
can be run on a LabVIEW environment using the MathScript node. This activity uses the MathScript node
to implement the convolution sum and the difference equation.
III. LEARNING ACTIVITIES
Activity 6.1 – Generation of Elementary Discrete-time Signals Using the MathScript node.
1. Create the VI act06-01_delta.vi. This will generate a unit sample sequence in which the user can
specify at what time index n will the sequence start and finish, and also the number of samples k this
signal will be delayed (for positive k) or advanced (for negative k).
2. Build the FP and BD as shown.

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 2

Signals, Spectra and Signal Processing

Insert a MathScript node structure. Right-click on the left edge of the structure and choose Add
Input, naming this input as k. This variable will be the number of samples the unit sample
sequence will be delayed or advanced. Add two more inputs. Name them as n1 and n2. These will
be the starting and ending time-index of the sequence respectively. Create numeric controls for
each of the inputs.
Type the following in the first line of the MathScript node:
n = [n1:n2]; x = [(n-k) == 0];
This will generate an array n which will have n1 as the first element, increments by one and ends
up with n2 as the last element. The array x will be generated by testing each of the values of array
n minus the number of delay if it is equal to zero. It returns 1 when it is true.
Create the outputs nand x. Switch to FP. Create an Array indicator, naming this as n then place a
numeric indicator inside this array indicator. Insert another array indicator for x.
Switch to BD. Wire the n and x array indicators to the n and x outputs of the MathScript node to
the array nodes. Then right-click the n and x outputs of the MathScript node and select Choose
Data Type >1D Array > DBL 1D.
Switch back to FP. Insert an XY Chart. Name this as delta(n). Configure the chart as shown:

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 3

Signals, Spectra and Signal Processing

Wire the X input terminal of the Build XY Graph to the n output of the MathScript node and the Y
input terminal to the x output of the MathScript node.

3. Save the VI. Type in various values fork, n1 and n2, then run the VI.
Question: Generate the following sequences and plot the resulting waveform.

δ(n)
for −20 ≤ n ≤ 20

δ(n − 5)
for −20 ≤ n ≤ 20

δ(n + 5)
for −20 ≤ n ≤ 20

4. Edit the icon of this VI as shown below. Then set the connections of this VI with k, n1 and n2 as inputs
and x and n as outputs. Save the VI

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 4

Signals, Spectra and Signal Processing

5. Replicate act06-01_delta.vi and rename the VI as act06-01_step.vi Modify the FP and BD as shown.

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 5

Signals, Spectra and Signal Processing
6. Save the VI. Type in various values for k, n1 and n2, then run the VI.
Question: What is the functionality of the VI?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Question: Complete the table below by plotting the output signal from the XY chart.

u(n)
for −20 ≤ n ≤ 20

u(n − 5)
for −20 ≤ n ≤ 20

u(n + 5)
for −20 ≤ n ≤ 20

7. Edit the icon of this VI as shown below. Then set the connections of this VI with k, n1 and n2 as inputs
and x and n as outputs. Save the VI.

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 6

Signals, Spectra and Signal Processing

8. Replicate act06-01_step.vi and rename the VI as act06-01_realexp.vi Modify the FP and BD as
shown.

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 7

Signals, Spectra and Signal Processing

Configure the XY Graph. Under the Display Format of the Properties of XY Graph, choose
Amplitude (Y-Axis) and change the Format string to %0.1g.

9. Edit the icon of this VI as shown below. Then set the connections of this VI with a, n1 and n2 as inputs
and x and n as outputs. Save the VI.

10. Type in various values for a, n1 and n2, then run the VI.
Question: What is the functionality of the VI? What can be said about the value of a with respect to
the form of the plot?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Question: Generate the following sequences and complete the table below by plotting the output
waveform at the XY Graph.

0.8
for −10 ≤ n ≤ 10

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 8

Signals, Spectra and Signal Processing

1
for −10 ≤ n ≤ 10

1.2
for −10 ≤ n ≤ 10

11. Create the VI act06-01.vi which will generate x(n) = 0.8 u(n − 4) for −20 ≤ n < 20 using the
previously created Vis as subVIs.
Question: Plot the signal generated above.

Activity 6.2 – The Convolution Sum.
1. Create the VI act06-02.vi. This VI will compute the convolution sum of two signals x (n) = a u(n)
and x (n) = u(n) − u(n − N) and plot the results, as well as the individual signals on an XY chart.
2. Build the BD and FP as shown. The XY charts are configured in the same manner as those used in the
previous sub-activity. This VI also uses the previously created Vis as subVIs to generate the signals to be
convolved

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 9

Signals, Spectra and Signal Processing

3. Save the VI. Type in various values for a, n1, n2 and N, then run the VI.

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 10

Signals, Spectra and Signal Processing
Question: Discuss the functionality of the VI. Include in the discussions the meaning of the
variables N, n1, n2, a, y and n.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Question: Evaluate the convolution sum of each of the pairs of signals for − ≤ ≤
using the
VI. Complete the table below. Verify the values obtained by using alternate methods (manual
calculation or a spreadsheet can be used for this purpose).
Pair Of Signals

Convolution Sum

Plot

x (n) = 0.9 u(n)
x (n) = u(n) − u(n − 3)

x (n) = 1.1 u(n)
x (n) = u(n) − u(n − 5)

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 11

Signals, Spectra and Signal Processing
4. Modify act06-02.vi to compute for the convolution sum of the pairs of sequences given in the table
below. The code inside the MathScript node may be modified, and new subVIs generating a sinusoidal
signal can be created.
Question: Complete the table below by plotting the convolution sum of the following pairs of
signals from − ≤ ≤ .
x (n) = n[u(n + 10) − u(n − 20)], x (n) = (1.2) [u(n + 5) − u(n − 10)]

x (n) = n[u(n + 10) − u(n − 20)], x (n) = cos(0.1πn)[u(n) − u(n − 30)]

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 12

Signals, Spectra and Signal Processing
Activity 6.3 – The Difference Equation
1. The difference equation can be implemented in the MathScript node as the function filter. Create
the VI act06-03_impresp.vi. This VI generates the impulse response of a difference equation defined by
coefficients b and a. The parameters n1 and n2 determine the duration of the impulse response.

The subVIdelta(n) is the VI act06-01_delta.vi which generates an impulse sequence whose
duration is between n1 and n2.

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 13

Signals, Spectra and Signal Processing

The function filter implements the difference equation by specifying the coefficients of y(n)
and its delayed versions in the vector a and coefficients of x(n) and its delayed versions in the
vector b. The vector x contains the vector of the input signal x(n).
The graph in the FP is an XY Graph which have the same configuration as before.

2. Save the VI. To plot the impulse response of the difference equation y(n) − y(n − 1) + 0.9y(n −
2) = x(n), form the vectors b and a. The vector b is the coefficients of x(n) and its delayed versions
grouped together on one side of the equation, thus b = [1]. The vector a is the coefficients of y(n) and its
delayed versions grouped together on one side of the equation, thus a = [1 −1 0.9]. Type in these
values in the FP then run the VI.
Question: Plot the impulse response of the above given difference equation for − ≤ ≤
.
What can be said about the causality and stability of this system?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Question: Determine the impulse response of the system using hand calculations. Then plot the
few values of the impulse response determined using hand calculations. Does this agree with the
one obtained from the VI?
Impulse Response:

Plot:

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 14

Signals, Spectra and Signal Processing
3. Replicate the VI and name the new VI as act06-03_stepresp.vi. Modify the VI so that this will plot the
step response of a system described by a difference equation.
Question:Using this VI, plot the step response of the system ( ) − ( − ) + . ( − ) =
( )for − ≤ ≤
. Determine an equation for the step response of the system using hand
calculations and plot the few values.
Step Response:

Plot:

Question: Compare the form of impulse and step responses. Observe the value to which each
response approach to as the time index grows larger, and the value for which each of the inputs
that generated the responses approach as time index grows larger.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 15

Signals, Spectra and Signal Processing
IV. CONCLUSIONS
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
V. MACHINE PROBLEM
1. Implement a system that will generate the autocorrelation and crosscorrelation of signals using the
MathScript node of LabVIEW. Apply this system to a practical signal.
2. A “simple” digital differentiator is given by
y(n) = x(n) − x(n − 1)
which computes a backward first-order difference of the input sequence. Implement this differentiator using
the MathScript node. Do the following:
 Plot the impulse and step response of this system. Investigate the causality and stability of this
system.
 Implement this differentiator on the following sequences and plot the results.
o x(n) = 5[u(n) − u(n − 20)]; a rectangular pulse
o x(n) = n[u(n) − u(n − 10)] + (20 − n)[u(n − 10) − u(n − 20)]; a triangular
pulse.
o x(n) = sin

[u(n) − u(n − 10)]; a sinusoidal pulse.

Comment on the appropriateness of the differentiator based on the observations drawn from the
results obtained above.

VI. REFERENCES
Kehtarnavaz, N. & Kim, N. (2005).Digital Signal Processing System-Level Design Using LabVIEW.Oxford,
United Kingdom: Elsevier, Inc.
Proakis, J. &Manolakis D. (2006). Digital Signal Processing: Principles, Algorithms and Applications 4th
Edition. New Jersey, USA: Prentice-Hall.
Ingle, V. &Proakis, J. (1997).Digital Signal Processing Using MATLAB V.4. Boston, New York: PWS
Publishing Company.
Activity No. 6 – Analysis of Discrete-time Systems: Convolution and Difference Equation

Page 16