






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
SOLUTION Laboratory Exercise Material Type: Notes; Class: Digital Signal Processing; Subject: Electrical and Computer Engineering; University: United Arab Emirates University; Term: Forever 1989;
Typology: Study notes
1 / 30
This page cannot be seen from the preview
Don't miss anything!























Project 1.1 Unit sample and unit step sequences
A copy of Program P1_1 is given below.
% Program P1_ % Generation of a Unit Sample Sequence clf; % Generate a vector from -10 to 20 n = -10:20; % Generate the unit sample sequence u = [zeros(1,10) 1 zeros(1,20)]; % Plot the unit sample sequence stem(n,u); xlabel('Time index n');ylabel('Amplitude'); title('Unit Sample Sequence'); axis([-10 20 0 1.2]);
Answers :
-10 -5 0 5 10 15 20
0
1
Time index n
Amplitude
Unit Sample Sequence
% Program P1_1, MODIFIED for Q1. % Generation of a DELAYED Unit Sample Sequence clf; % Generate a vector from -10 to 20 n = -10:20; % Generate the DELAYED unit sample sequence u = [zeros(1,21) 1 zeros(1,9)]; % Plot the DELAYED unit sample sequence stem(n,u); xlabel('Time index n');ylabel('Amplitude'); title('DELAYED Unit Sample Sequence'); axis([-10 20 0 1.2]);
-10 -5 0 5 10 15 20
0
1
Time index n
Amplitude
DELAYED Unit Sample Sequence
-10 -5 0 5 10 15 20
0
1
Time index n
Amplitude
ADVANCED Unit Step Sequence
Project 1.2 Exponential signals
% Program P1_ % Generation of a complex exponential sequence clf; c = -(1/12)+(pi/6)i; K = 2; n = 0:40; x = Kexp(c*n); subplot(2,1,1); stem(n,real(x)); xlabel('Time index n');ylabel('Amplitude'); title('Real part'); subplot(2,1,2); stem(n,imag(x)); xlabel('Time index n');ylabel('Amplitude'); title('Imaginary part');
% Program P1_ % Generation of a real exponential sequence clf; n = 0:35; a = 1.2; K = 0.2; x = K*a.^n; stem(n,x); xlabel('Time index n');ylabel('Amplitude');
Answers:
Q1.6 The complex-valued exponential sequence generated by running Program P1_2 is shown
Time index n
Amplitude
Real part
Time index n
Amplitude
Imaginary part
Time index n
Amplitude
It can be changed to generate sequences with different lengths as follows (give an example
Project 1.3 Sinusoidal sequences
% Program P1_ % Generation of a sinusoidal sequence n = 0:40; f = 0.1; phase = 0; A = 1.5; arg = 2pifn - phase; x = Acos(arg); clf; % Clear old graph stem(n,x); % Plot the generated sequence axis([0 40 -2 2]); grid; title('Sinusoidal Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis;
Answers:
Sinusoidal Sequence
Time index n
Amplitude
Sinusoidal Sequence
Time index n
Amplitude
A sinusoidal sequence of frequency 1.1 generated by modifying Program P1_4 is shown below.
Sinusoidal Sequence
Time index n
Amplitude
0 5 10 15 20 25 30 35 40
-1.
-0.
0
1
2
Sinusoidal Sequence
Time index n
Amplitude
0 5 10 15 20 25 30 35 40
-1.
-0.
0
1
2
Sinusoidal Sequence
Time index n
Amplitude
Project 1.4 Random signals
Answers:
Q1.26 The MATLAB program to generate and display a random signal of length 100 with elements uniformly distributed in the interval [–2, 2] is given below along with the plot of the random
% Program Q1_ % Generation of a uniform random sequence n = 0:99; A = 2; rand('state',sum(100clock)); % "seed" the generator % rand(1,100) is uniform in [0,1] % rand(1,100)-0.5 is uniform in [-0.5,0.5] % 4(rand(1,100)-0.5) is uniform in [-2,2] x = 2A(rand(1,length(n))-0.5); clf; % Clear old graph stem(n,x); % Plot the generated sequence axis([0 length(n) -round(2(A+0.5))/2 round(2(A+0.5))/2]); grid; title('Uniform Random Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis;
Gaussian Random Sequence
Time index n
Amplitude
Q1.28 The MATLAB program to generate and display five sample sequences of a random sinusoidal signal of length 31
% Generates the "deterministic stochastic process" % called for in Q1.28. n = 0:30; f = 0.1; Amax = 4; phimax = 2pi; rand('state',sum(100clock)); % "seed" the generator A = Amaxrand; % NOTE: successive calls to rand without arguments % return a random sequence of scalars. Since this % random sequence is "white" (uncorrelated), it is % not necessary to re-seed the generator for phi. phi = phimaxrand; % generate the sequence arg = 2pifn + phi; x = Acos(arg); % plot clf; % Clear old graph
stem(n,x); % Plot the generated sequence Ylim = round(2*(Amax+0.5))/2; axis([0 length(n) -Ylim Ylim]); grid; title('Sinusoidal Sequence with Random Amplitude and Phase'); xlabel('Time index n'); ylabel('Amplitude'); axis;
0 5 10 15 20 25 30
0
1
2
3
4
Sinusoidal Sequence with Random Amplitude and Phase
Time index n
Amplitude
0 5 10 15 20 25 30
0
1
2
3
4
Sinusoidal Sequence with Random Amplitude and Phase
Time index n
Amplitude
0 5 10 15 20 25 30
0
1
2
3
4
Sinusoidal Sequence with Random Amplitude and Phase
Time index n
Amplitude
Project 1.5 Signal Smoothing
% Program P1_ % Signal Smoothing by Averaging clf; R = 51; d = 0.8(rand(R,1) - 0.5); % Generate random noise m = 0:R-1; s = 2m.*(0.9.^m); % Generate uncorrupted signal x = s + d'; % Generate noise corrupted signal subplot(2,1,1); plot(m,d','r-',m,s,'g--',m,x,'b-.'); xlabel('Time index n');ylabel('Amplitude'); legend('d[n] ','s[n] ','x[n] '); x1 = [0 0 x];x2 = [0 x 0];x3 = [x 0 0]; y = (x1 + x2 + x3)/3; subplot(2,1,2); plot(m,y(2:R+1),'r-',m,s,'g--'); legend( 'y[n] ','s[n] ');
xlabel('Time index n');ylabel('Amplitude');
Answers:
0 5 10 15 20 25 30 35 40 45 50
0
5
10
Time index n
Amplitude
d[n] s[n] x[n]
0 5 10 15 20 25 30 35 40 45 50
0
2
4
6
8
Time index n
Amplitude
y[n] s[n]