0% found this document useful (0 votes)
34 views

Terminal Lab Paper: Function

This document contains code for performing discrete Fourier transforms (DFT) and inverse discrete Fourier transforms (IDFT) on signals. It defines functions to calculate the DFT and IDFT matrices and uses them to transform signals. It also contains code for filtering signals using direct form 1 and direct form 2 filter implementations and compares the frequency responses of the two filters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Terminal Lab Paper: Function

This document contains code for performing discrete Fourier transforms (DFT) and inverse discrete Fourier transforms (IDFT) on signals. It defines functions to calculate the DFT and IDFT matrices and uses them to transform signals. It also contains code for filtering signals using direct form 1 and direct form 2 filter implementations and compares the frequency responses of the two filters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

TERMINAL LAB PAPER

%QUESTION NO 1
R=5
a=16
xn=0:15
x=[R 2*R 3*R 4*R 5*R 6*R 7*R 8*R 9*R 10*R 11*R 12*R 13*R 14*R 15*R]
f1=fft(x)
figure
subplot(211)
stem(abs(f1))
xlabel('Time')
ylabel('Amplitude')
title('fft')
f2= FFT_DIT(x)
subplot(212)
stem(abs(f2))
xlabel('Time')
ylabel('Amplitude')
title(' fft')

FUNCTION
%QUESTION NO 1
R=5
a=16
xn=0:15
x=[R 2*R 3*R 4*R 5*R 6*R 7*R 8*R 9*R 10*R 11*R 12*R 13*R 14*R 15*R]
f1=fft(x)
figure
subplot(211)
stem(abs(f1))
xlabel('Time')
ylabel('Amplitude')
title('fft')
f2= FFT_DIT(x)
subplot(212)
stem(abs(f2))
xlabel('Time')
ylabel('Amplitude')
title(' fft')
%QUESTION NO 2
clc
clear all
close all
R=5
M=5
N=5
n=[0:1:N-1]
k=[0:1:M-1]
x=(n>0)
Wn=exp(-j*2*pi/N)
nk=n.*k
F=Wn.^nk
b=x.*F
subplot(211)
stem(n,x)
xlabel('Time Period')
ylabel('Amplitude Of Signal')
title('u(n)')
subplot(212)
stem (n,b)
xlabel('Time Period OF SIGNAL')
ylabel('Amplitude OF Signal')
title('y(n)')

FUNCTON
function [y] = DFT(xn,N,b,k ) %DFT-IDFT
if b==1 % To compute DFT
n=[0:1:N-1];% row vector for n
k=[0:1:N-1];% row vector for k
WN=exp(-j*2*pi/N); % wn factor
nk=n'*k
WNnk=WN.^nk
fprintf('DFT Matrix')
y=xn*WNnk ;%DFT matrix
% To compute IDFT
else if b==0
n=[0:1:N-1]
k=[0:1:N-1]
WN=exp(-j*2*pi/N);
nk=n'*k
WNnk=WN.^(-nk);
fprintf('IDFT Matrix')
y=(xn*WNnk)./N ;
end
end
Results

%QUESTION NO 3
clc
clear all
close all
b=[2 1 3]
a=[1]
S_Direct1=dfilt.df1(b,a)
S_Direct2=dfilt.df2(b,a)
fvtool(S_Direct1)
fvtool(S_Direct2)
gain=dfilt.scalar(1)
%%

Question 4

You might also like