DSL - Experiment 5 Aim: Write Matlab Program To Study The Sampling & Reconstruction Process
DSL - Experiment 5 Aim: Write Matlab Program To Study The Sampling & Reconstruction Process
Aim: Write Matlab program to study the Sampling & Reconstruction Process
A. SAMPLING
Matlab Code
%Sampling
num_points=1000; %sampling rate i.e. samples/sec
T=1/num_points; %sampling period/interval T
ts = 0:T:t_time; %sampling instants for total duration of signal
ns = 0:length(ts)-1; %no. of samples for total duration of signal
x_samples = mag*sin(2*pi*fm/num_points*ns); %sample values
𝑡
where 𝐻 (𝑗Ω) is the inverse Fourier transform of ℎ(𝑡 ) = 𝑠𝑖𝑛𝑐 ( ). Therefore, 𝑥𝑟 (𝑡) is:
𝑇
Matlab Code
%Reconstruction
x_recon=0; %initialising reconstructed signal
for k=0:length(x_samples)-1
l=k:-1:-(length(t)-1)+k; %taking ns number of past and future samples
x_recon=x_recon+x_samples(k+1)*sinc(l); %reconstruction using interpolation
end
subplot(3,1,3); %Plotting the reconstructed signal
plot(t,x_recon);
title('Reconstructed signal')
xlabel('t (sec)');
ylabel('x_r(t)');