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

Signal Processin1

The document outlines a signal processing experiment involving the generation, sampling, and reconstruction of a signal using Fourier Transform and low pass filtering techniques. It includes the creation of a signal composed of two frequencies, the application of a sampling function, and the analysis of the signal in both time and frequency domains. The results are visualized through various plots demonstrating the original and reconstructed signals as well as the frequency response of the filter.

Uploaded by

2dbsbp4nrz
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)
7 views4 pages

Signal Processin1

The document outlines a signal processing experiment involving the generation, sampling, and reconstruction of a signal using Fourier Transform and low pass filtering techniques. It includes the creation of a signal composed of two frequencies, the application of a sampling function, and the analysis of the signal in both time and frequency domains. The results are visualized through various plots demonstrating the original and reconstructed signals as well as the frequency response of the filter.

Uploaded by

2dbsbp4nrz
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

SIGNAL PROCESSING

EXP 7
% Clear workspace, close all figures, and clear command window
clear all, close all, clc
% Define parameters
n = 120;
f1 = 10; % Signal frequency
t = 1/n * (0:1:119); % Time vector
x = 10 * cos(2*pi*f1.*t); % Signal
xf = fft(x); % Fourier Transform of the signal
freq = -n/2 : n/2-1; % Frequency vector
fs = 40; % Sampling Frequency
y = zeros(size(t));
y(1:n/fs:end) = 1; %Sampling Function
yf = fft(y); % Fourier Transform of the Sampling Function
z = y .* x; % Multiplication of the Signal with Sampling signal the in time domain
(Sampled Signal)
zf = fft(z); % Fourier Transform of the Sampled Signal
%% Low Pass Filter with cutoff frequency fs/2
flf = [zeros(1, 0.5*(length(t)-fs)) ones(1,fs+1) zeros(1,0.5*(length(t)-fs)-1)]; %
Low pass filter in Frequency domain
figure(1)
subplot(2,1,1)
plot(freq, flf)
grid on, xlabel('Frequency, Hz'), ylabel('Magnitude, fft(LPF)')
title('Frequency response of filter')
flf_t = real(fftshift(ifft(fftshift(flf)))); % Low pass filter in Time domain
subplot(2,1,2)
plot(freq, flf_t)
grid on, xlabel('Time, t'), ylabel('Time domain Response')
title('Time Domain Response of Filter')
%% Multiplication in Frequency Domain
kf = fftshift(flf) .* zf; % Multiplication in frequency domain
k = ifft(kf); %Reconstructed signal in Time domain
figure(2)
subplot(3,1,1)
plot(t, x)
grid on, xlabel('Time, t'), ylabel('x(t)'), title('Original signal')
subplot(3,1,2)
plot(t, k)
grid on, xlabel('Time, t'), ylabel('x(t)'), title('Reconstructed signal')
subplot(3,1,3)
plot(freq, abs(fftshift(kf))) % Plot the Spectrum of the reconstructed Signal
grid on, xlabel('Frequency, Hz')
ylabel('|fft (x)|'), title('Magnitude response of XF')
x = 10 * cos(2*pi*f1.*t)+ 5 * cos(2*pi*f2.*t); where f1=10 Hz and f2=20 Hz

% Clear workspace, close all figures, and clear command window


clear all, close all, clc
% Define parameters
n = 120;
f1 = 10; % Signal frequency
f2 = 20; % Signal frequency
t = 1/n * (0:1:119); % Time vector
x = 10 * cos(2*pi*f1.*t)+5* cos(2*pi*f2.*t); % Signal
xf = fft(x); % Fourier Transform of the signal
freq = -n/2 : n/2-1; % Frequency vector
fs = 40; % Sampling Frequency
y = zeros(size(t));
y(1:n/fs:end) = 1; %Sampling Function
yf = fft(y); % Fourier Transform of the Sampling Function
z = y .* x; % Multiplication of the Signal with Sampling signal the in time domain
(Sampled Signal)
zf = fft(z); % Fourier Transform of the Sampled Signal
%% Low Pass Filter with cutoff frequency fs/2
flf = [zeros(1, 0.5*(length(t)-fs)) ones(1,fs+1) zeros(1,0.5*(length(t)-fs)-1)]; %
Low pass filter in Frequency domain
figure(1)
subplot(2,1,1)
plot(freq, flf)
grid on, xlabel('Frequency, Hz'), ylabel('Magnitude, fft(LPF)')
title('Frequency response of filter')
flf_t = real(fftshift(ifft(fftshift(flf)))); % Low pass filter in Time domain
subplot(2,1,2)
plot(freq, flf_t)
grid on, xlabel('Time, t'), ylabel('Time domain Response')
title('Time Domain Response of Filter')
%% Multiplication in Frequency Domain
kf = fftshift(flf) .* zf; % Multiplication in frequency domain
k = ifft(kf); %Reconstructed signal in Time domain
figure(2)
subplot(3,1,1)
plot(t, x)
grid on, xlabel('Time, t'), ylabel('x(t)'), title('Original signal')
subplot(3,1,2)
plot(t, k)
grid on, xlabel('Time, t'), ylabel('x(t)'), title('Reconstructed signal')
subplot(3,1,3)
plot(freq, abs(fftshift(kf))) % Plot the Spectrum of the reconstructed Signal
grid on, xlabel('Frequency, Hz')
ylabel('|fft (x)|'), title('Magnitude response of XF')

You might also like