You are on page 1of 12

CT 303 Lab Exercises 01 :

Name : Soni Kirtan Brijeshbhai


Id : 202101197

: Experiment 1 :

Natural Sampling and Its reconstruction:


1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ

Sample and hold :

1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ

Flat top :

1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ

: Experiment 2 :

Natural Sampling (1KHZ sine wave freq.):


2KHZ Sampling freq. 4KHZ Sampling freq.

8KHZ Sampling freq. 16KHZ Sampling freq.

32KHZ Sampling freq. 64KHZ Sampling freq.


Natural Sampling (2KHZ sine wave freq.):

2KHZ Sampling freq. 4KHZ Sampling freq.

8KHZ Sampling freq. 16KHZ Sampling freq.

32KHZ Sampling freq. 64KHZ Sampling freq.


Sample and hold Sampling (1KHZ sine wave freq.):

64KHZ Sampling freq. 32KHZ Sampling freq.

16KHZ Sampling freq. 8KHZ Sampling freq.

4KHZ Sampling freq. 2KHZ Sampling freq.


Sample and hold Sampling (2 KHZ sine wave freq.):

64KHZ Sampling freq. 32KHZ Sampling freq.

16KHZ Sampling freq. 8KHZ Sampling freq.

4KHZ Sampling freq. 2KHZ Sampling freq.


Flat top Sampling (1KHZ sine wave freq.):

64KHZ Sampling freq. 32KHZ Sampling freq.

16KHZ Sampling freq. 8KHZ Sampling freq.

4KHZ Sampling freq. 2KHZ Sampling freq.


Flat top Sampling (2 KHZ sine wave freq.):

64KHZ Sampling freq. 32KHZ Sampling freq.

16KHZ Sampling freq. 8KHZ Sampling freq.

4KHZ Sampling freq. 2KHZ Sampling freq.


: Experiment 3 :

: 2nd Order Low pass Filter :


Natural Sampling and Its reconstruction:

1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ

Sample and hold :

1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ

Flat top :

1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ
: 4th Order Low pass Filter :

Natural Sampling and Its reconstruction:

1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ

Sample and hold :

1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ

Flat top :

1kHZ sine wave freq. Sampling freq. 8HZ 2kHZ sine wave freq. Sampling freq. 8HZ
Experiment 4:

Code fragment 2.5.1 :

ts=1/16; %sampling interval

time_interval = 0:ts:1; %sampling time instants

%%time domain signal evaluated at sampling instants

signal_timedomain = sin(pi*time_interval); %sinusoidal pulse in our example fs_desired =


1/160; %desired frequency granularity

Nmin = ceil(1/(fs_desired*ts)); %minimum length DFT for desired frequency granularity


%for e cient computation, choose FFT size to be power of 2

N t = 2^(nextpow2(Nmin)) %FFT size = the next power of 2 at least as big as Nmin


%Alternatively, one could also use DFT size equal to the minimum length

%N t=Nmin;

%note: t function in Matlab is just the DFT when N t is not a power of 2

%freq domain signal computed using DFT

% t function of size N t automatically zeropads as needed

signal_freqdomain = ts* t(signal_timedomain,N t);

% tshift function shifts DC to center of spectrum

signal_freqdomain_centered = tshift(signal_freqdomain);

fs=1/(N t*ts); %actual frequency resolution attained

%set of frequencies for which Fourier transform has been computed using DFT

freqs = ((1:N t)-1-N t/2)*fs;

%plot the magnitude spectrum

plot(freqs,abs(signal_freqdomain_centered));

xlabel(’Frequency’);

ylabel(’Magnitude Spectrum’);

ff
ff
ff
ff
ffi
ff
ff
ff
ff
ff
ff
ff
ff
ff
4(a) Use the function contFT to compute the Fourier transform of s(t) = 3sinc(2t − 3),
where the unit of time is a microsecond, the signal is sampled at the rate of 16 MHz, and
truncated to the range [−8, 8] microseconds. We wish to attain a frequency resolution of 1
KHz or better. Plot the magnitude of the Fourier transform versus frequency, making sure
you specify the units on the frequency axis. Check that the plot conforms to your
expectations.

clear all;
close all;
clc;
t=10^(-6);
dt = (1/16)*t;
time_int=-8*t:dt:8*t;
x = 3.*sinc(2*time_int-3);
tstart = -8*t;
df_desired = 1000; contFT(x,tstart,dt,df_desired);
function [X,f,df] = contFT(x,tstart,dt,df_desired)
Nmin=max(ceil(1/(df_desired*dt)),length(x));
Nfft = 2^(nextpow2(Nmin)); X=dt*fftshift(fft(x,Nfft));
df=1/(Nfft*dt);
f = ((0:Nfft-1)-Nfft/2)*df; X=X.*exp(-j*2*pi*f*tstart);
figure(1);
plot(f,abs(X));
xlabel('Fourier Transform Magnitude'); ylabel('Frequency in hz');
end

(b) Plot the phase of the Fourier transform obtained in (a) versus frequency (again,
make sure the units on the frequency axis are speci ed). What is the range of
frequencies over which the phase plot has meaning?

clear all;
close all;
clc;
t=10^(-6);
dt = (1/16)*t;
time_int=-8*t:dt:8*t;
x = 3.*sinc(2*time_int-3) ;
tstart = -8*t;
df_desired = 1000; contFT(x,tstart,dt,df_desired);
function [X,f,df] = contFT(x,tstart,dt,df_desired)
Nmin=max(ceil(1/(df_desired*dt)),length(x));
Nfft = 2^(nextpow2(Nmin)); X=dt*fftshift(fft(x,Nfft));
df=1/(Nfft*dt);
f = ((0:Nfft-1)-Nfft/2)*df; X=X.*exp(-j*2*pi*f*tstart);
plot(f,angle(X));
xlabel('Fourier Transform');
ylabel('Frequency in hz');
end




fi



You might also like