Of DSP 5
Of DSP 5
Of DSP 5
Title:
Discrete Time Signals and Systems in Frequency Domain.
In the previous two labs we dealt with the time-domain representation of discrete-time signals and
systems, and investigated their properties. Further insight into the properties of such signals and systems
is obtained by their representation in the frequency-domain.
Code of task 1:
% Program P4_1
% Evaluation of the DTFT
clf;
% Compute the frequency samples of the DTFT
w = -6*pi:8*pi/511:6*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('\omega /\pi'); ylabel('Phase in radians');
Result:
Q 4.1 What is the expression of the DTFT being evaluated in Program P4_1?
ANS:IN THIS PART dtft being evaluated by taking its value
w = -6*pi:8*pi/511:6*pi;
num = [2 1];den = [1 -0.6];
h = freqz(num, den, w);
and repeat Question Q4.3. Comment on your results. Can you explain the jump in the phase spectrum?
The jump can be removed using the MATLAB command unwrap. Evaluate the phase spectrum with the
jump removed.
Task 2 CODE:
% Program P4_2
% Time-Shifting Properties of DTFT clf;
w = -pi:2*pi/255:pi; % frequency vector for evaluating DTFT
D = 10; % Amount of time shift in samples
num = [1 2 3 6 5 6 7 8 9];
% h1 is the DTFT of original sequence
% h2 is the DTFT of the time shifted sequence
h1 = freqz(num, 1, w);
h2 = freqz([zeros(1,D) num], 1, w); subplot(2,2,1)
% plot the DTFT magnitude of the original sequence
plot(w/pi,abs(h1));grid
title('Magnitude Spectrum of Original Sequence','FontSize',8)
Result:
Result:
Q 4.6 Run the program P4_3 and comment on your results.
The program P4_3 generates four plots of the magnitude and phase spectra of the original and frequency-shifted
sequences. The magnitude spectrum of the original sequence has a peak at the frequency corresponding to the center
of the sequence. The magnitude spectrum of the shifted sequence shows the same peak, but shifted in frequency by
the amount specified in the program. The phase spectra show a linear trend for the original sequence, and a linear
shift for the shifted sequence
The results show that the magnitude spectrum of the pointwise product of the DTFTs is identical to the
magnitude spectrum of the DTFT of the convolved sequence. The phase spectra of the pointwise product
and the convolved sequence are also identical. These results confirm the convolution property of the
DTFT, which states that the DTFT of the convolution of two sequences is equal to the pointwise product
of their DTFTs.
Task 5 Code:
clf;
w = -pi:2*pi/255:pi; % frequency vector for evaluating DTFT
% original ramp sequence
% note: num is nonzero for 0 <= n <= 3.
num = [1 2 3 4];
L = length(num)-1;
h1 = freqz(num, 1, w)
% Program P4_5 1, w); % DTFT of original ramp sequence
h2 = freqz(fliplr(num), 1, w);
h3 = exp(w*L*i).*h2;
% plot the magnitude spectrum of the original ramp sequence
subplot(2,2,1)
plot(w/pi,abs(h1));grid
title('Magnitude Spectrum of Original Sequence','FontSize',8)
xlabel('\omega /\pi');
ylabel('Amplitude');
% plot the magnitude spectrum of the time reversed ramp sequence
subplot(2,2,2)
plot(w/pi,abs(h3));grid
title('Magnitude Spectrum of Time-Reversed Sequence','FontSize',8)
xlabel('\omega /\pi');
ylabel('Amplitude');
% plot the phase spectrum of the original ramp sequence
subplot(2,2,3)
plot(w/pi,angle(h1));grid
title('Phase Spectrum of Original Sequence','FontSize',8)
xlabel('\omega /\pi');
ylabel('Phase in radians');
% plot the phase spectrum of the time reversed ramp sequence
subplot(2,2,4)
plot(w/pi,angle(h3));grid
title('Phase Spectrum of Time-Reversed Sequence','FontSize',8)
xlabel('\omega /\pi');
ylabel('Phase in radians');
RESULT:
The program implements the time-reversal operation by using the flipl r function to reverse the order of
the original sequence, and then multiplying the resulting frequency response by the complex exponential
exp(wLi), where L is the length of the original sequence minus one, and w is the frequency vector used to
evaluate the DTFT. This multiplication by exp(wLi) introduces a phase shift that corresponds to a time
reversal operation in the time domain