Professional Documents
Culture Documents
Name:__________________________________
Date Performed: _________________________
Rating:__________________________
Date Submitted: __________________
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.
Page 1
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.
Page 2
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:
Page 3
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
Page 4
5. Replicate act06-01_delta.vi and rename the VI as act06-01_step.vi Modify the FP and BD as shown.
Page 5
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.
Page 6
Page 7
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
Page 8
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.
Page 9
3. Save the VI. Type in various values for a, n1, n2 and N, then run the VI.
Page 10
Convolution Sum
Plot
Page 11
Page 12
Page 13
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:
Page 14
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.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Page 15
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