0% found this document useful (0 votes)
15 views33 pages

Lab6 NguyenHoaiNam EEACIU20104

Uploaded by

datmasuto10a19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views33 pages

Lab6 NguyenHoaiNam EEACIU20104

Uploaded by

datmasuto10a19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

VIETNAM NATIONAL UNIVERSITY – HOCHIMINH CITY

INTERNATIONAL UNIVERSITY

SCHOOL OF ELECTRICAL ENGINEERING

Digital Signal Processing Laboratory


EE093IU

FOURIER ANALYSIS OF DISCRETE-TIME


SIGNALS
Submitted by
Nguyễn Hoài Nam_EEACIU20104

Date Submitted: 01/06/2024.


Date Performed: 25/05/2024.
Lab Section: 6
Course Instructor : T.Q.Hien.
GRADING GUIDELINE FOR LAB REPORT
Number Content Score Comment

1 Format (max 9%)

- Font type Yes No

- Font size Yes No

- Lab title Yes No

- Page number Yes No

- Table of contents Yes No

- Header/Footer Yes No

- List of figures (if exists) Yes No

- List of tables (if exists) Yes No

- Lab report structure Yes No

English Grammar and Spelling (max 6%)


2
- Grammar Yes No

- Spelling Yes No

3 Data and Result Analysis (max 85%)

Total Score

Signature:

Date:
International University School of Electrical Engineering

Table of Contents

List of Figures .................................................................................................................................... II

List of Tables .................................................................................................................................... III

1 Theoretical Background ................................................................................................................ 1


1.1 Discrete-Time Fourier Transform ............................................................................................... 1
1.2 Discrete Fourier Transform ........................................................................................................... 3
1.3 Inverse Discrete Fourier Transform ........................................................................................... 6
1.4 Fast Fourier Transform.................................................................................................................... 7
1.5 Relationship between DFT and DTFT ........................................................................................ 9
1.6 Relationship between Fourier Transform and Discrete Fourier Transform ........... 11

2 Experimental Procedure ............................................................................................................. 12


2.1 Problem 1: ........................................................................................................................................... 12
2.2 Problem 2 ............................................................................................................................................. 13
2.3 Problem 3 ........................................................................................................................................... 15
2.4 Problem 4 ........................................................................................................................................... 16
2.5 Problem 5 ........................................................................................................................................... 19

3 Experimental Results ................................................................................................................... 21


3.1 Problem 1 ............................................................................................................................................. 21
3.2 Problem 2 ............................................................................................................................................. 22
3.3 Problem 3 ........................................................................................................................................... 23
3.4 Problem 4 ........................................................................................................................................... 24
3.5 Problem 5 ........................................................................................................................................... 26

4 Discussion of Results .................................................................................................................... 28

[Course’s name] I [Course number]


International University School of Electrical Engineering

List of Figures
Figure 1: Result of problem 1 ............................................................................................................... 21
Figure 2: Result of problem 2 ............................................................................................................... 22
Figure 3: Result of problem 3 ............................................................................................................... 23
Figure 4: Result of problem 4a and 4b ............................................................................................. 24
Figure 5: Result of problem 4c ............................................................................................................. 25
Figure 6: Result of problem 4d ............................................................................................................. 25
Figure 7: Graph of problem 5a ............................................................................................................. 27
Figure 8: Energy calculations in matlab of problem 5b .............................................................. 27

[Course’s name] II [Course number]


International University School of Electrical Engineering

List of Tables
Table 1: Code of problem 1 ..................................................................................................................... 13
Table 2: Code of problem 2 .................................................................................................................... 15
Table 3: Code of problem 3 .................................................................................................................... 16
Table 4: Code of problem 4 .................................................................................................................... 18
Table 5: Code of problem 5 .................................................................................................................... 20

[Course’s name] III [Course number]


International University School of Electrical Engineering

1 Theoretical Background

1.1 Discrete-Time Fourier Transform

Discrete-time Fourier transform (DTFT) is the counterpart transform to the


continuous-time Fourier transform (CTFT) when dealing with discrete-time signals, i.e.,
when dealing with signals described by a function x[n],n ∈ Z. The mathematical expression
of the DTFT is

𝑋(𝜔) = ∑ 𝑥[𝑛]𝑒 −𝑗𝜔𝑛


𝑛= −∞

The DTFT is a continuous complex-valued function of the cyclic frequency

𝜔. A sufficient condition for the existence of the DTFT X(ω) of a signal x[n] is

Moreover, the DTFT is always a periodic function with period 2π. In order to return
from the frequency domain ω back to the discrete-time domain n, we apply inverse DTFT.
The mathematical expression of the inverse DTFT is

The computation of the DTFT X(ω) of a signal x[n] is easily obtained directly from (1)

Example 1

Compute the DTFT X(ω) of the signal x[n] = 0. 8𝑛 , 0 ≤ n ≤ 20 and plot X(ω) over the
frequency intervals −π ≤ ω ≤ π and −5π ≤ ω ≤ 5π.

Digital Signal Processing Laboratory 1 EE093IU


International University School of Electrical Engineering

Example 2

Compute and plot the DTFT of the signal x[n] = 0.6𝑛 u[n].

Digital Signal Processing Laboratory 2 EE093IU


International University School of Electrical Engineering

1.2 Discrete Fourier Transform

In order to implement DTFT analysis of a signal on a computer, it is necessary to obtain

samples ωk from the frequency ω. This leads to a second type of Fourier transform
appropriate for discrete-time signals, the discrete Fourier transform (DFT). The N -point DFT
of a discrete-time signal x[n] is denoted by Xk or X(k) or X(ωk). It is defined in the discrete-
time interval 0 ≤ n ≤ N − 1 and is computed according to

The DFT Xk of a sequence x[n] is a function of k and is completely specified by its values for

k = 0,1, ... , N − 1 that is, from the N values X1, X2, ... , XN−1. Typically, Xk are complex

numbers. Hence, they can be expressed in polar form as

Digital Signal Processing Laboratory 3 EE093IU


International University School of Electrical Engineering

Xk = |Xk|𝑒 −j∠Xk , k = 0,1, ... , N – 1

Where

|Xk| is the magnitude of Xk, and ∠Xk is the phase of Xk.

Alternatively, Xk is expressed as

Xk = Re{Xk} + jIm{Xk}, k = 0,1, ... , N – 1

Where Re{Xk} is the real part of Xk and is given by:

where the second equality is derived from the fact that x(0)cos(0) = x(0). The imaginary

part Im{Xk} of Xk is given by

Example 3:

Compute the DFT Xk of the sequence x[n] = [1,2,2,1], 0 ≤ n ≤ 3. Plot the magnitude,

the phase, the real part, and the imaginary part of Xk.

Digital Signal Processing Laboratory 4 EE093IU


International University School of Electrical Engineering

Digital Signal Processing Laboratory 5 EE093IU


International University School of Electrical Engineering

Example 4:

Write a function that computes the DFT Xk of a sequence x[n]. Compute through your

function the DFT of the discrete-time signal x[n] = [1,2,2,1], 0 ≤ n ≤ 3.

1.3 Inverse Discrete Fourier Transform

Suppose that the DFT Xk of a discrete-time signal x[n] is known. The signal x[n] can be

derived from the N DFT points Xk, k = 0,1, ... , N − 1 by applying the inverse discrete Fourier
transform (IDFT). The IDFT of a sequence Xk is given by

Example 5:

Compute the IDFT of the sequence Xk = [6, −1 − j, 0, −1 + j], 0 ≤ k ≤ 3.

Digital Signal Processing Laboratory 6 EE093IU


International University School of Electrical Engineering

Write a function that computes the IDFT of a sequence

1.4 Fast Fourier Transform

Computing an N-point DFT or IDFT directly from its definition can be a computationally
expensive process. More specifically, looking into Equation (4) we notice that for every value
that k takes, i.e., for every Xk, k = 0, ... , N − 1 multiplications must be performed. Thus, in
order to compute the entire sequence Xk, k = 0, ... , N − 1 we must perform 𝑁 2 multiplications.
If the discrete-time signal x[n] is complex valued, things get difficult, since one multiplication
of two complex numbers requires four multiplications between real numbers. Hence,
computing the DFT (or IDFT) directly from the definition is usually too slow for real-time
applications. In order to reduce the computational effort needed, an efficient algorithm (with
many variants) is available for the DFT computation. This algorithm is called fast Fourier
transform algorithm or FFT algorithm. FFT is based on a ‘‘divide and conquer’’ technique;
that is, the original problem of N points is divided in two symmetric subproblems of N/2

Digital Signal Processing Laboratory 7 EE093IU


International University School of Electrical Engineering

points. If N/2 is even number, the problem of N/2 points is divided in two subproblems of
N/4 points.

If N is a power of 2, i.e, N = 2𝑃 then only a 2-point DFT has to be computed. The DFT Xk
of a sequence x[n] is computed in MATLAB through a FFT algorithm, with the command fft.
The syntax is X = fft(x), where x is the sequence x[n] and X is the DFT Xk.

Remark

FFT must not be confused with DFT. FFT is an algorithm that computes the DFT of a
sequence. An alternative syntax of the fft command is X = fft(x,N). Using this syntax we derive
the N-point DFT of an M-point sequence. If M > N, the sequence x[n] is truncated; while if M
< N, the sequence x[n] is zero-padded.

Digital Signal Processing Laboratory 8 EE093IU


International University School of Electrical Engineering

The IDFT of a sequence Xk is computed by the MATLAB command ifft. The syntax is x
= ifft(X) or x = ifft(X, N) if an N-point IDFT is required.

1.5 Relationship between DFT and DTFT

In this section, we establish the relationship between the two types of Fourier
transform that are applicable to discrete-time signals, namely, the DFT and the DTFT. It
states that the DFT Xk is actually a sampling in the frequency of the DTFT X(ω), or in other
words the DFT is a sampling of the continuous spectrum of a discrete-time signal. More
precisely, we can state that the DFT sequence Xk is equal to the DTFT X(ω) when X(ω) is
2𝜋𝑘
evaluated at the points ωk = , k = 0,1, ... , N − 1. To verify the relationship between DTFT
𝑛

and DFT, consider the truncated discrete-time signal x[n] = 0.9n, 0 ≤ n ≤ 7. The DTFT is
2𝜋𝑘
evaluated at the frequencies ωk = , k = 0,1, ... , N − 1 and is compared to the DFT of x[n].
𝑛

Digital Signal Processing Laboratory 9 EE093IU


International University School of Electrical Engineering

Example 6:

Let x[n] be a random sequence of 21 elements. Plot in the same figure the DTFT X(ω)
2𝜋𝑘
of x[n] for 0 ≤ n ≤ 2π and the DFT of x[n] versus the frequencies 𝜔𝑘 = , , k = 0,1, ... , N
𝑛
− 1.

Digital Signal Processing Laboratory 10 EE093IU


International University School of Electrical Engineering

1.6 Relationship between Fourier Transform and Discrete Fourier Transform

In this section, we discuss how the CTFT is approximated by the DFT. Suppose that
X(ω) denotes the Fourier transform of a continuous-time signal x(t). The procedure followed
in order to approximate X(ω) through samples obtained from the FFT algorithm is

- The signal x(t) is sampled with sampling time T; that is, we obtain the discrete-time
signal x[nT], n = 0,1, ... , N − 1.

- The DFT Xk, k = 0,1, ... , N − 1 of the discrete-time signal x[nT] is computed.

- The Fourier transform X(Ω) can be approximated at the frequencies Ωk = 2πk/N,


k=0,1, ... , N − 1 from the DFT samples according to

As N is getting larger or the sampling time T is getting smaller, we obtain a better

approximation of X(Ω) by the sequence X(Ωk), which is computed according to (10).

Example 7:

Digital Signal Processing Laboratory 11 EE093IU


International University School of Electrical Engineering

Compute and plot the magnitude of the Fourier transform X(Ω) of the continuous-time
signal x(t) = 2 − 3t, 0 ≤ t ≤ 2. Also compute and plot in the same graph the magnitude of the
approximate sequence X(Ωk) for N = 128 and T = 0. 1.

2 Experimental Procedure

2.1 Problem 1:

Plot the magnitude and the phase of the DTFT X(ω) of the signal x[n] = cos(πn⁄3), 0 ≤

n ≤ 10 over the frequency intervals −3π ≤ ω ≤ 3π and −7π ≤ ω ≤ 7π.

% Define the signal


n = 0:10;
x_n = cos(pi * n / 3);

% Define the frequency ranges


omega1 = linspace(-3 * pi, 3 * pi, 1000);
omega2 = linspace(-7 * pi, 7 * pi, 1000);

Digital Signal Processing Laboratory 12 EE093IU


International University School of Electrical Engineering

% Compute the DTFT


X_omega1 = arrayfun(@(w) sum(x_n .* exp(-1j * w * n)), omega1);
X_omega2 = arrayfun(@(w) sum(x_n .* exp(-1j * w * n)), omega2);

% Plot the magnitude and phase for -3? ? ? ? 3?


figure;
subplot(2, 2, 1);
plot(omega1, abs(X_omega1));
title('Magnitude of DTFT (|X(?)|) for -3? ? ? ? 3?');
xlabel('?');
ylabel('|X(?)|');
grid on;

subplot(2, 2, 2);
plot(omega1, angle(X_omega1));
title('Phase of DTFT (?X(?)) for -3? ? ? ? 3?');
xlabel('?');
ylabel('?X(?)');
grid on;

% Plot the magnitude and phase for -7? ? ? ? 7?


subplot(2, 2, 3);
plot(omega2, abs(X_omega2));
title('Magnitude of DTFT (|X(?)|) for -7? ? ? ? 7?');
xlabel('?');
ylabel('|X(?)|');
grid on;

subplot(2, 2, 4);
plot(omega2, angle(X_omega2));
title('Phase of DTFT (?X(?)) for -7? ? ? ? 7?');
xlabel('?');
ylabel('?X(?)');
grid on;

% Adjust the layout


sgtitle('DTFT of x[n] = cos(\pi n / 3), 0 \leq n \leq 10');

Table 1: Code of problem 1


2.2 Problem 2

Plot the magnitude, the angle, the real part and the imaginary of the DFT Xk of the signal

Digital Signal Processing Laboratory 13 EE093IU


International University School of Electrical Engineering

x[n] = 3cos(2πn⁄3), 0 ≤ n ≤ 64.

clc
clear all;
close all;

% Define the signal


n = 0:64; % 0 to 64 inclusive
x_n = 3 * cos((2 * pi * n) / 3);

% Compute the DFT


X_k = fft(x_n);

% Compute magnitude, angle, real part, and imaginary part


magnitude = abs(X_k);
angleX = angle(X_k);
real_part = real(X_k);
imaginary_part = imag(X_k);

% Define frequency bins


k = 0:length(X_k)-1;

% Plotting
figure;

subplot(2, 2, 1);
stem(k, magnitude, 'filled');
title('Magnitude of DFT');
xlabel('Frequency Bin');
ylabel('Magnitude');

subplot(2, 2, 2);
stem(k, angleX, 'filled');
title('Angle of DFT');
xlabel('Frequency Bin');
ylabel('Angle (radians)');

subplot(2, 2, 3);
stem(k, real_part, 'filled');
title('Real Part of DFT');
xlabel('Frequency Bin');
ylabel('Real Part');

subplot(2, 2, 4);
stem(k, imaginary_part, 'filled');
title('Imaginary Part of DFT');

Digital Signal Processing Laboratory 14 EE093IU


International University School of Electrical Engineering

xlabel('Frequency Bin');
ylabel('Imaginary Part');

% Adjust layout
sgtitle('DFT Analysis of x[n] = 3cos(2?n/3)');

Table 2: Code of problem 2


2.3 Problem 3

Consider the sequence x[n] = 5cos(2πn⁄3), 0 ≤ n ≤ 19. Plot in the same graph the
DTFT of x[n] over the frequency interval 0 ≤ ω ≤ 2ω and the DFT of x[n] versus the
frequency points ωk = 2πk/N, k = 0,1, ... , N − 1.

clc
clear all
% Define the sequence
n = 0:19;
x_n = 5 * cos(2 * pi * n / 3);

% Define the DTFT frequency range


omega = linspace(0, 2 * pi, 1000);

% Compute the DTFT


X_omega = arrayfun(@(w) sum(x_n .* exp(-1j * w * n)), omega);

% Compute the DFT


N = length(x_n);
X_k = fft(x_n);
omega_k = (2 * pi / N) * (0:N-1);

% Plot the DTFT and DFT on the same graph


figure;

% Plot DTFT
plot(omega, abs(X_omega), 'b', 'DisplayName', 'DTFT');
hold on;

% Plot DFT
stem(omega_k, abs(X_k), 'r', 'DisplayName', 'DFT');
hold off;

% Add labels and title


xlabel('\omega');
ylabel('|X(\omega)|');

Digital Signal Processing Laboratory 15 EE093IU


International University School of Electrical Engineering

title('DTFT and DFT of x[n] = 5cos(2\pi n / 3), 0 \leq n \leq


19');
legend('show');
grid on;

Table 3: Code of problem 3


2.4 Problem 4

clc
clear all
close all

R = 1; % Ohms
C = 0.1; % Farads

Digital Signal Processing Laboratory 16 EE093IU


International University School of Electrical Engineering

%% Part (a) and (b): Frequency response of the RC low-pass and


high-pass filters
f = logspace(0, 4, 1000); % Frequency range from 1 Hz to 10
kHz
H_low = 1 ./ (1 + 1i * 2 * pi * f * R * C); % Low-pass
transfer function
H_high = (1i * 2 * pi * f * R * C) ./ (1 + 1i * 2 * pi * f * R
* C); % High-pass transfer function

figure;
subplot(2,1,1);
semilogx(f, 20*log10(abs(H_low)), 'b', f,
20*log10(abs(H_high)), 'r');
title('Magnitude Response of Low-Pass and High-Pass Filters');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
legend('Low-Pass Filter', 'High-Pass Filter');
grid on;

subplot(2,1,2);
semilogx(f, angle(H_low), 'b', f, angle(H_high), 'r');
title('Phase Response of Low-Pass and High-Pass Filters');
xlabel('Frequency (Hz)');
ylabel('Phase (radians)');
legend('Low-Pass Filter', 'High-Pass Filter');
grid on;

%% Part (c) and (d): Time-domain response to a square wave


input
fs = 2000; % Sampling frequency in Hz
t = 0:1/fs:1; % Time vector for 1 second
f_square = 7; % Frequency of the square wave in Hz
Vi = square(2 * pi * f_square * t); % Square wave signal

% Low-pass filter impulse response


h_low = exp(-t/(R*C)) .* (t >= 0); % Impulse response of the
RC low-pass filter
Vo_low = conv(Vi, h_low, 'same') / fs; % Filtered output

% High-pass filter impulse response


h_high = diff([0 exp(-t/(R*C))]) / fs; % Impulse response of
the RC high-pass filter
Vo_high = conv(Vi, h_high, 'same') / fs; % Filtered output

figure;
subplot(2,1,1);
plot(t, Vi, 'k', t, Vo_low, 'b');

Digital Signal Processing Laboratory 17 EE093IU


International University School of Electrical Engineering

title('Response of Low-Pass Filter to Square Wave');


xlabel('Time (s)');
ylabel('Amplitude');
legend('Input (Vi)', 'Low-Pass Output (Vo)');
grid on;

subplot(2,1,2);
plot(t, Vi, 'k', t, Vo_high, 'r');
title('Response of High-Pass Filter to Square Wave');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Input (Vi)', 'High-Pass Output (Vo)');
grid on;

% Compare responses from part (c) and (d)


figure;
plot(t, Vo_low, 'b', t, Vo_high, 'r');
title('Comparison of Low-Pass and High-Pass Filter Responses');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Low-Pass Output (Vo)', 'High-Pass Output (Vo)');
grid on;
Table 4: Code of problem 4

Digital Signal Processing Laboratory 18 EE093IU


International University School of Electrical Engineering

2.5 Problem 5

clc
clear all
close all
% Given sequence parameters
N = 50;
n = 0:N-1;
x = 0.7 .^ n;

% Compute DTFT
omega = linspace(0, 2 * pi, 1000);
X_omega = arrayfun(@(w) sum(x .* exp(-1j * w * n)), omega);

% Compute DFT
X_k = fft(x);

% Plot DTFT and DFT


figure;
plot(omega, abs(X_omega), 'LineWidth', 1.5);
hold on;
stem(2 * pi * (0:N-1) / N, abs(X_k), 'r', 'filled');
xlabel('Frequency \omega');
ylabel('Magnitude');

Digital Signal Processing Laboratory 19 EE093IU


International University School of Electrical Engineering

title('DTFT and DFT of x[n] = 0.7^n, 0 \leq n \leq 49');


legend('|X(\omega)| (DTFT)', '|X_k| (DFT)');
grid on;
hold off;

% Compute the energy in the discrete-time domain


energy_time_domain = sum(abs(x).^2);

% Compute the energy from the DFT


energy_dft = (1/N) * sum(abs(X_k).^2);

% Compute the energy from the DTFT


energy_dtft = (1/(2*pi)) * trapz(omega, abs(X_omega).^2);

% Display the results


disp(['Energy in the discrete-time domain: ',
num2str(energy_time_domain)]);
disp(['Energy from the DFT: ', num2str(energy_dft)]);
disp(['Energy from the DTFT: ', num2str(energy_dtft)]);

Table 5: Code of problem 5

Digital Signal Processing Laboratory 20 EE093IU


International University School of Electrical Engineering

3 Experimental Results

3.1 Problem 1

Figure 1: Result of problem 1


Comment: To solve this problem, First I creates a vector n containing integers from 0 to 10 for
0<n<10 and generate the signal x_n. Next, for the frequency intervals I create a vector omega1
with 1000 points linearly spaced between (− 3 𝜋,3π) and omega2 between ( − 7 𝜋, 7π).
X_omega1 and X_omega2 are computed using arrayfun, which applies a function to each element
of omega1 and omega2, respectively. Finnaly I plot the signal of magnitude and phase of
X_omega1 and X_omega2 by function plot.
Magnitude signal
𝜋
For the range − 3 𝜋 ≤ 𝜔 ≤ 3 𝜋 the magnitude plot show significant peaks at 𝜔 = ± 3 ,which

corresponds to the frequency of the cosine signal.


For the extended range − 7 𝜋 ≤ 𝜔 ≤ 7 𝜋 −7π≤ω≤7π, similar peaks be observed at
intervals of 2 𝜋 due to the periodicity of the DTFT.

Digital Signal Processing Laboratory 21 EE093IU


International University School of Electrical Engineering

3.2 Problem 2

Figure 2: Result of problem 2

Comment: In this problem, I creates a vector n containing integers from 0 to 64 for 0< n < 64 then
I define the signal x_n. Function ‘fft’ computes the DFT of the signal x_n using the Fast Fourier
Transform (FFT) algorithm. Respectively,
magnitude = abs(X_k) for computes the magnitude of each frequency component.
angleX = angle(X_k) for computes the phase angle
real_part = real(X_k) to extracts the real part of frequency
imaginary_part = imag(X_k) to extracts the imaginary part
Next, I creates a vector k representing the frequency, ranging from 0 to the length of (X_k-1).
Finally, I plot all the result I get by using stem and subplot combine as I show on the figure 2

Digital Signal Processing Laboratory 22 EE093IU


International University School of Electrical Engineering

3.3 Problem 3

Figure 3: Result of problem 3


Comment: In problem 3, first I Creates a sequence n from 0 to 19 for 0<n<19 then I
define the sequence x_n.

omega = linspace(0, 2 * pi, 1000) to generates 1000 equally spaced points between
0 and 2π for the DTFT frequency range.

X_omega = arrayfun(@(w) sum(x_n .* exp(-1j * w * n)), omega): Computes the


DTFT of x_n at each frequency in omega. The arrayfun function applies the given anonymous
function to each element of omega. For each frequency w, the DTFT is calculated as
∑𝑁−1
𝑛=0 𝑥[𝑛]𝑒
−𝑗𝑤𝑛

N = length(x_n): Finds the length of the sequence x_n

fft(x_n) to computes the Discrete Fourier Transform (DFT) of x_n

Finnaly I plot the graph using stem(omega_k, abs(X_k), 'r', 'DisplayName', 'DFT')

Digital Signal Processing Laboratory 23 EE093IU


International University School of Electrical Engineering

By plotting both the DTFT and DFT, we can observe how the continuous frequency
spectrum (DTFT) relates to the discrete frequency spectrum (DFT) obtained by sampling the
sequence.

3.4 Problem 4

Figure 4: Result of problem 4a and 4b

Digital Signal Processing Laboratory 24 EE093IU


International University School of Electrical Engineering

Figure 5: Result of problem 4c

Figure 6: Result of problem 4d

Digital Signal Processing Laboratory 25 EE093IU


International University School of Electrical Engineering

Comment: In problem 4, first I define the value of C and R then I create a logarithmically
spaced vector of 1000 points ranging from 100 (1 Hz) to 104 (10 kHz).

As the figure from the problem 4, we can see that is a low Pass Filter and the transfer
function H(f) is given by

When we interchange the position of R to C and C to R the circuit become High Pass
Filter, now the transfer function is given by

After that, I define 2 tranfer function based on the fomula as below

H_low = 1 ./ (1 + 1i * 2 * pi * f * R * C);

H_high = (1i * 2 * pi * f * R * C) ./ (1 + 1i * 2 * pi * f * R * C);

semilogx(f, 20*log10(abs(H_low)), 'b', f, 20*log10(abs(H_high)), 'r'): Plots the


magnitude response in decibels (dB) on a logarithmic x-axis. The magnitude is calculated
using abs(H_low) and abs(H_high), and converted to dB with 20*log10(). The low-pass
filter is plotted in blue, and the high-pass filter is plotted in red.

For question c, I Sets the sampling frequency to 2000 Hz and frequency of the square wave
1
to 7 Hz then create a time vector t from 0 to 1 second with a sampling interval of . Next, I
𝑓𝑠

generate a square wave signal with a frequency of 7 Hz using the time vector t ‘Vi = square(2
* pi * f_square * t)’

3.5 Problem 5

Digital Signal Processing Laboratory 26 EE093IU


International University School of Electrical Engineering

Figure 7: Graph of problem 5a

Figure 8: Energy calculations in matlab of problem 5b

Comment: First, I define the squence x_n and create a vector n from 0 to 49. I generate
1000 equally spaced points between 0 and 2π for the DTFT frequency range by function
linspace. Next I compute the DTFT of x at each frequency in omega X_omega =
arrayfun(@(w) sum(x .* exp(-1j * w * n)), omega) based on formula ∑𝑁−1
𝑛=0 𝑥[𝑛]𝑒
−𝑗𝑤𝑛

I use function fft() to compute the Discrete Fourier Transform (DFT) of x

After that, I use plot(omega, abs(X_omega), 'LineWidth', 1.5) to plot the magnitude
of the DTFT∣X(ω)∣ versus omega with a line width of 1.5 and stem(2 * pi * (0:N-1) / N,
abs(X_k), 'r', 'filled') to plots the magnitude of the DFT∣X k ∣

Digital Signal Processing Laboratory 27 EE093IU


International University School of Electrical Engineering

energy_time_domain = sum(abs(x).^2): Computes the energy of the sequence x in


the time domain. The energy is given by ∑𝑁−1
𝑛=0 |𝑥[𝑛]|
2

energy_dft = (1/N) * sum(abs(X_k).^2): Computes the energy using the DFT. The
energy is normalized by 1/N to account for the length of the DFT. The formula used here is
1
∑𝑁−1
𝑛=0 |𝑥[𝑘]|
2
𝑁

energy_dtft = (1/(2*pi)) * trapz(omega, abs(X_omega).^2): Computes


the energy using the DTFT. The energy is integrated over the frequency range
1 2𝜋
using the trapezoidal rule (trapz). The formula is ∫ |𝑋(𝜔)|2 𝑑𝜔
2𝜋 0

By plotting both the DTFT and DFT, we can observe how the continuous frequency
spectrum (DTFT) relates to the discrete frequency spectrum (DFT) obtained by sampling the
sequence. The energy calculations further validate the consistency between time and
frequency domain representations

4 Discussion of Results

In lab section 5, we had practice the problem about the Discrete-Time Fourier Transform. After
this lab student gained practical and theoretical knowledge about discrete-time signals and their
frequency representations. We learned how to compute and visualize the DTFT and DFT, validate
theoretical concepts such as Parseval's theorem, and apply these techniques using MATLAB.
These skills are essential for anyone working in digital signal processing, communications, or
related fields.

Digital Signal Processing Laboratory 28 EE093IU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy