Digital Signal Processing Experiments Instruction

yakzephyrAI and Robotics

Nov 24, 2013 (3 years and 8 months ago)

83 views


1

Digital Signal Processing Experiments Instruction

Basic knowledge of MATLAB

You could use command
help

to get the help information for a certain command in
MATLAB

Command Window.

E.g. >help stem

MATLAB would not accept filenames start with numbers or othe
r symbols except
letters. E.g. lx3.m is correct file name but 34lx.m is not correct.

Capital letters and Small letters are different in MATLAB.

Attention


Z
oom in figures into 1/4 page size in your report!

Project 1.
GENERATION OF SEQUENCES

Run

following program and try to answer questions.
(Texts

following % are
notations.)

% Generation of a Unit Sample Sequence

clear all
;


% Generate a vector from
-
1
0 to 20

n =
-
10:20;

% Generate the unit sample sequence

usamp

= [zeros(1,10) 1 zeros(1,20)];

% Plot the unit sample sequence

stem(n,u
samp
);

xlabel('Time index n');ylabel('Amplitude');

title('Unit Sample Sequence');

axis([
-
10 20 0 1.2]);

Q1.
1


Get the help

information for command
zeros

and try to m
odif
y

the
p
rogram to generate a delayed unit sample sequence u
samp
d[n] with a delay of 11
samples.

< Insert program code here. Copy from m
-
file(s) and paste. >

< Insert MATLAB figure(s) here. Copy from figure wi
ndow(s) and paste. >

Q1.
2

Get the help information for command
zeros

and
ones
. Then try to m
odif
y

the p
rogram to generate a unit step sequence
u
s
tep
[n] is given below along with the
sequence generated by running this program.



2

< Insert program code here.
Copy from m
-
file(s) and paste. >

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >



Project

2 Linear
Convolution

Run

following program and try to answer questions.
(Texts

following % are
notations.)

clear all
;

close all

h = [3 2 1
-
2 1 0
-
4 0 3];


% impulse response

x = [1
-
2 3
-
4 3 2 1];


% input sequence

y = conv(h,x);

% compute the convolution

n = 0:14;

subplot(2,1,1);

stem(n,y);

xlabel('Time index n'); ylabel('Amplitude');

title('Output Obtained by Convolution'); grid;

x1 = [x
zeros(1,
2
)];


y1 = filter(h,1,x1);

subplot(2,1,2);

stem(n,y1);

xlabel('Time index n'); ylabel('Amplitude');

title('Output Generated by Filtering'); grid;

Q2.
1


Try to use

command
length
to check the sampling numbers for sequences x,
h, y, x1 and y1.
Write

down their relations

.

The rea
son for using x1[n] as the input, obtained by zero
-
padding x[n], for
generating y1[n] is

.

Q2.2


The sequences y[n] and y1[n] generated by running
the above
program

are
shown below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >


The difference between y[n] and y1[n] is

.




T
ry to change one parameter in x1 to make y1[n] has same figure as y[n].



3

Project
3
DTFT Computation

Run

following program and try to answer questions.
(Texts

following % are
notations.)

% Evaluation of the DTFT

cl
ear all
;

close all; clc;

% Compute the frequency samples of the DTFT

w =
-
4*pi:8*pi/511:4*pi;

num = [2 1];den = [1
-
0.6];

h

= freqz(num, den, w);

% Plot the DTFT

subplot(2,1,1)

plot(w/pi,real(h));grid

title('Real part of H(e^{j
\
omega})')

xlabel('
\
omega /
\
pi');

ylabel('Amplitude');

subplot(2,1,2)

plot(w/pi,imag(h));grid

title('Imaginary part of H(e^{j
\
omega})')

xlabel('
\
omega /
\
pi');

ylabel('Amplitude');

pause

subplot(2,1,1)

plot(w/pi,abs(h));grid

title('Magnitude Spectrum |H(e^{j
\
omega})|')

xlabel('
\
omega /
\
pi');

ylabel('Amplitude');

subplot(2,1,2)

plot(w/pi,angle(h));grid

title('Phase Spectrum arg[H(e^{j
\
omega})]')

xlabel('
\
om
ega /
\
pi');

ylabel('Phase in radians');

Q3.1

The expression of the DTFT being evaluated in
above

program
is

.


4


The function of the pause command is

.

Q3.
2

The plots generated by running
program

are shown below:

< Insert MATLAB f
igure(s) here. Copy from figure window(s) and paste. >


The DTFT is a


function of

.


Its period is

.


The types of symmetries exhibited by the four plots are as follows:





.



Project 4
DFT

and IDFT

Computations

The MATLAB program to compute and plot the L
-
point DFT X[k] of a length
-
N
sequence x[n] with L


N and then to compute and plot the IDFT of X[k] is
given
below:

% compute L
-
point dft for sequence

clear all
; close all; clc;

L=16; n = 0:(L
-
1);

x = [0 2 4 6 8 10 12 14 16];

xzp=[x zeros(1,(L
-
length(x)))];

% DFT calculation

XF = fft(xzp);

% IDFT calculation

xt = ifft(XF);

% plot the result

subplot(3,1,1)

s
tem(n,abs(XF));grid

title('Magnitude of DFT of Sequence x');

subplot(3,1,2)

stem(n,angle(XF));grid

title('Phase of DFT of Sequence x');

subplot(3,1,3)


5

stem(n,xt);grid

title(' IDFT of XF');


Q4.1

observe the result of above program.

< Insert MATLAB figure(s
) here. Copy from figure window(s) and paste. >

plot figure of sequence x,

< Insert program code here. Copy from m
-
file(s) and paste. >

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

compare it with figure of xt. They have such
relations

.

Q4.2

change L to 32, run the program again,

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

compare the result with L=16, then large L means

.