Laboratory Manual 4: Discrete Time Fourier Transform & Discrete Fourier Transform
Laboratory Manual 4: Discrete Time Fourier Transform & Discrete Fourier Transform
Roll # : 14F-8355
Section : A
Laboratory Manual 4
Discrete Time Fourier Transform
&
Tools used:
MATLAB
Description:
Task0:
x=[0 1 0 5 7 6 3 4 7 1 9 8 7 8 3 2]
Code:
clc
clearall
fs=1000
ts=1/(fs)
x=[0 1 0 5 7 6 3 4 7 1 9 8 7 8 3 2]
t=0:ts:0.015
plot (t,x,'r')
xlabel('time (t)' )
ylabel('Amplitude')
title('Time Domain Signal')
Explanation:
Task 1:
Plot frequency spectrum of x=[1 1 1 0 0]; Fs=1000; across its frequency vector with fft(x) and fft(x,N). See the
difference by increasing N and explain it.
Code:
clc
clearall
x=[1 1 1 0 0]
l=length(x)
fs=1000
ts=1/fs
t=0:ts:4*ts
subplot(221)
stem(t,x,'r')
xlabel('time (t)' )
ylabel('Amplitude')
title('Signal in Time domain')
n=1024
y=fft(x,n)
t1=(0:(length(y)-1))*(fs/length(y))
subplot(222)
stem(t1,y,'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform')
y1=fft(x,n)
subplot(223)
stem(t1,abs(y1),'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform Magnitude')
p=angle(y)
subplot(224)
stem(t1,p,'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform Magnitude Angle')
First of all , I made the signal in time domain. Then I took discrete time fourier transform of signal. I
took the magnitude and phase spectrum.
Task 2:
A=sin(2*pi*440*(0:1/8000:0.5));
sound(A,8000);
Code:
clc
clearall
t=0:1/8000:0.5
a=sin(2*pi*440*t)
fs=8000
subplot(331)
plot(t,a,'r')
xlabel('time (t)' )
ylabel('Amplitude')
title('Signal in Time domain')
y=fft(a)
y1=length(y)
t1=(0:(length(y)-1))*(fs/y1)
subplot(332)
stem(t1,y,'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform')
y1=fft(a)
subplot(223)
stem(t1,abs(y1),'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform Magnitude')
p=angle(y1)
subplot(224)
stem(t1,p,'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform Magnitude Angle')
Plot (s) (time domain + frequency domain):
Explanation:
First of all , I made the signal in time domain. Then I took discrete time fourier transform of signal. I
took the magnitude and phase spectrum.
Task 3:
Code:
clearall
clc
clearall
loadchirp.mat
x=y'
fs=8000
ts=1/(fs)
t=(0:length(x)-1)*ts
sound(x,fs)
subplot(221)
plot (t,x,'r')
xlabel('time (t)' )
ylabel('Amplitude')
title('Chirp Signal')
y=fft(x)
subplot(222)
stem(t,y,'r')
xlabel('Frequency (f)' )
ylabel('Amplitude')
title('Chirp Signal in Frequency Domain')
y1=fft(x)
subplot(223)
stem(t,abs(y1),'r')
xlabel('Omega (w)' )
ylabel('Amplitude')
title('Chirp signal Magnitude')
p=angle(y)
subplot(224)
stem(t,p,'r')
xlabel('Omega (w)' )
ylabel('Amplitude')
title('Chirp Signal Angle')
Explanation:
First I made a chirp signal by loading Chip.mat file. Then I draw chirp signal in frequency domain.
Then I took magnitude and phase spectrum.
Task 4:
Form a signal S containing a 50 Hz sinusoid of amplitude 0.7 and a 120 Hz sinusoid of amplitude 1. Corrupt the
signal with zero-mean white noise with a variance of 4.
X = S + 2*randn(size(t));
Listen both signals and observe the frequency spectrum of both S and X?
Fs=1000;
Length of signal = L =1000;
Code:
clearall
clc
clearall
fs=1000
ts=1/fs
t=0:ts:999;
f=50;
l=1000;
a=0.7;
x=a.*sin(2*pi*f*t);
a1=1;
f1=120;
x1=a1.*sin(2*pi*f1*t);
s=x+x1;
y=fft(s);
y1=abs(y);
subplot(221);
plot(t,y1);
xlabel('time (t)' );
ylabel('Amplitude');
title('Magnitude of spectrum sum of 2 signal');
b=s+2*randn(size(t));
subplot(222);
plot(t,b);
xlabel('time (t)' );
ylabel('Amplitude');
title('Noisy signal ');
b1=fft(b)
subplot(223);
plot(t,b);
xlabel('time (t)' );
ylabel('Amplitude');
title('Noisy signal fft');
b2=abs(b);
subplot(224);
plot(t,b2);
xlabel('time (t)' );
ylabel('Amplitude');
title('Magnitude of Noisy signal');
First of all, I add two different signals. Then I made a noisy signal and add with the sum of two signals.
Then I took its magnitude and phase in frequency domain.
Task 5:
myvoice=audiorecorder;
recordblocking(myvoice,5);
play(myvoice);
Y=getaudiodata(myvoice);
Code:
< Insert program code here. Copy from m-file(s) and paste. >
< Insert program plot here. Copy from Matlab figure and paste. >
Explanation:
Ans: In all the task, First of all I draw the signal in time domain. Then I take its discrete time fourier transform
(DTFT). I also observe the signal in frequency domain by magnitude and phase of signal.
Date:_______________ Signature:_______________