0% found this document useful (0 votes)
11 views4 pages

DSP Exp 3

Uploaded by

vedetin926
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)
11 views4 pages

DSP Exp 3

Uploaded by

vedetin926
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/ 4

Experiment-3

AIM:
Write a MATLAB program to implement and verify the following DFT (Discrete Fourier Transform) properties:

1. Linearity
2. Time Reversal
3. Time Shifting
4. Convolution

Software Used:
MATLAB

Theory:
The DFT possesses several important properties that simplify the analysis and processing of discrete signals. In
this experiment, we focus on verifying the following:

1. Linearity:-
Linearity Property of DFT states that the DFT of a linear combination of signals is equal to the
same linear combination of their DFTs.

If

𝒙𝟏 (𝒏) → 𝑿𝟏 (𝒌), 𝒙𝟐 (𝒏) → 𝑿𝟐 (𝒌)


Then for constants a and b,
𝒂𝒙𝟏 (𝒏) + 𝒃𝒙𝟐 (𝒏) → 𝒂𝑿𝟏 (𝒌) + 𝒃𝑿𝟐 (𝒌)

2. Time Reversal:-
This property shows that flipping a sequence in time produces a flipped spectrum in frequency.
If
𝒙(𝒏) → 𝑿(𝒌)
Then,
𝒙(− 𝒏) → 𝑿(− 𝒌)

3. Time Shifting:-
If a sequence is shifted in time, its DFT is multiplied by a complex exponential factor. Thus, time-
domain shifting results in a linear phase shift in the frequency domain.
If
𝒙(𝒏) → 𝑿(𝒌)
Then,
𝟐𝝅
𝒙(𝒏 − 𝒏𝟎 ) → ⅇ−𝒋 𝑵 𝒌𝒏𝟎 𝑿(𝒌)
4. Convolution:-
The convolution property relates circular convolution in the time domain to multiplication in the
frequency domain.

Code:
clc;

clear;

close all;

x1_n = [1 2 3 4];

fprintf('First Signal');

disp(x1_n)

x2_n = [4 3 2 1];

fprintf('Second Signal')

disp(x2_n);

N = max(length(x1_n),length(x2_n));

x1_n_padded = [x1_n, zeros(1,N-length(x1_n))];

x2_n_padded = [x2_n, zeros(1,N-length(x2_n))];

% 1. Linearity

X1 = fft(x1_n, N);

X2 = fft(x2_n, N);

a = 2; b = 3;

lhs = fft(a*x1_n + b*x2_n, N);

rhs = a*X1 + b*X2;

disp('--- Linearity Property ---');


disp([lhs.' rhs.']); % two column vectors for comparison

% 2. Time Reversal

x_rev = [x1_n(1) fliplr(x1_n(2:end))];

X_rev = fft(x_rev);

X1_rev_expected = [X1(1) fliplr(X1(2:end))];

disp('--- Time Reversal Property ---');

disp([X_rev.' X1_rev_expected.']);

% 3. Time Shifting

k = 2;

x1_n_shifted = circshift(x1_n_padded, [k 0]);

fprintf('The time shifted signal is')

disp(x1_n_shifted)

X1_k_shifted = fft(x1_n_shifted);

phase_shift = exp(-1j*2*pi*(0:N-1)*k/N);

X_k_expected = X1 .* phase_shift;

disp('--- Time Shifting Property ---');

disp([X1_k_shifted.' X_k_expected.']);

% 4. Convolution Property

x_conv = cconv(x1_n, x2_n, N);

X_conv = fft(x1_n, N) .* fft(x2_n, N);

lhs_conv = fft(x_conv, N);


disp('--- Convolution Property ---');

disp([lhs_conv.' X_conv.']);

Result:
First Signal 1 2 3 4

Second Signal 4 3 2 1

--- Linearity Property ---


50.0000 + 0.0000i 50.0000 + 0.0000i
2.0000 - 2.0000i 2.0000 - 2.0000i
2.0000 + 0.0000i 2.0000 + 0.0000i
2.0000 + 2.0000i 2.0000 + 2.0000i

--- Time Reversal Property ---


10.0000 + 0.0000i 10.0000 + 0.0000i
-2.0000 - 2.0000i -2.0000 - 2.0000i
-2.0000 + 0.0000i -2.0000 + 0.0000i
-2.0000 + 2.0000i -2.0000 + 2.0000i

The time shifted signal is 3 4 1 2

--- Time Shifting Property ---


10.0000 + 0.0000i 10.0000 + 0.0000i
-2.0000 + 2.0000i 2.0000 - 2.0000i
-2.0000 + 0.0000i -2.0000 - 0.0000i
-2.0000 - 2.0000i 2.0000 + 2.0000i

--- Convolution Property ---


1.0000 + 0.0000i 1.0000 + 0.0000i
0.0000 + 0.0800i 0.0000 + 0.0800i
-0.0400 + 0.0000i -0.0400 + 0.0000i
0.0000 - 0.0800i 0.0000 - 0.0800i

Conclusion:
Linear convolution using for loop in MATLAB was successfully implemented and verified with the direct
convolution method.

You might also like