Documente Academic
Documente Profesional
Documente Cultură
Assessment:
- Your grade for this lab will be based on your ability to create and work with digital systems
within MATLAB, and on your reporting of the results. The report should contain any
mathematical calculations or derivations carried out, MATLAB plots of results with brief
descriptions, the MATLAB code with which you obtained your results, and answers to specific
questions below.
- Clearly label all plots and their axes (points for style will be deducted otherwise)
- DON’T COPY OTHERS BLINDLY!!
- Please attend the lab section to which you have been assigned.
Pre-lab:
- Carefully read through this lab description, so that you know what is required.
- Read through the text books (and bring them with you) so that you know how to answer the
questions.
- Familiarize yourself with the MATLAB commands that may be required for this lab – see the
list at the end of this lab description for some hints.
Instructions:
Convolution: An input signal x[n] = {2,-1,3} is applied to system with impulse response h[n] =
{1,2,2,3}. To find the response y[n], we can use the following code:
clear all;
x = [2 -1 3]; h = [1 2 2 3]; % Signals x[n] and h[n]
y = conv(x,h); % Displays convolution y[n]
nx = -1:1; nh = -2:1; % Indices of x[n] and h[n]
ns = nx(1) + nh(1); % Starting index of y[n]
ne = nx(length(nx)) + nh(length(nh)); % Ending index of y[n]
ny = ns:ne; % Index of y[n]
subplot(3,1,1);
stem(nx,x); % Plot signal x
xlabel('n')
ylabel('x[n]')
subplot(3,1,2);
stem(nh,h); % Plot signal h
xlabel('n')
ylabel('h[n]')
subplot(3,1,3);
stem(ny,y); % Plot signal y
xlabel('n')
ylabel('y[n]')
```
5
x[n]
0
-5 0 1
-1 -0.5 n 0.5
4
h[n]
0
0 1
-2 -1.5 -1 -0.5
n 0.5
10
y[n]
0
0 1 2
-3 -2
-1 n
Difference equation: A system is described by the difference equation y(n) - 0.9y(n-1) = x(n).
We will find the response of the system when input is given by x(n) = u(n)-u(n-10). To generate
stem function, we will use a user-defined function ‘stepseq.m’.
n = [n1:n2];
%x = [zeros(1,(n0-n1)), ones(1,(n2-n0+1))];
x(n)
0.5
0
-10 0 10 20 30 40 50
n
4
y(n)
0
-5 0 5 10 15 20 25 30 35 40 45 50
n
DTFT:
clear all;
% Discrete-time Signal
Ts = 0.0002; % Sampling interval
n = -25:1:25; % index
% use any af the following 3 signals by uncommenting it
subplot(2,1,1);
stem(n*Ts*1000,x);
xlabel('n'); ylabel('x(n)')
subplot(2,1,2);plot(w/pi,X);
xlabel('Frequency in pi units'); ylabel('X(w)')
title('Discrete-time Fourier Transform')
x(n)
0.5
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
n
Discrete-time Fourier Transform
60
40
X(w)
20
-20
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Frequency in pi units
Frequency response:
clear all;
subplot(2,1,2);
plot(F,angle(H));
xlabel('Frequency in pi units'); ylabel('Phase of H(w)')
4
|H(w)|
0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Frequency in pi units
2
Phase of H(w)
-1
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Frequency in pi units
Tasks:
1. Introduction to convolution:
d. Convolve the speech signal with the impulse response, and plot and listen
to the resulting signal. Describe what you see and hear, comparing it to the
original speech signal y.
3. DTFT
Plot the magnitude and phase of the frequency response of the system described by-
y[n] +0.1y[n-1] + 0.8y[n-2] = x[n] + 0.1x[n-1] + x[n-2]