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

DSL - Experiment 5 Aim: Write Matlab Program To Study The Sampling & Reconstruction Process

This document contains a Matlab program to study the sampling and reconstruction process. It defines a message signal as a sine wave, samples the signal at regular intervals to get sample values, and then reconstructs the continuous signal from the samples using sinc interpolation. The program plots the original message signal, sampled signal, and reconstructed signal to analyze the sampling and reconstruction process.

Uploaded by

chucha
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)
47 views

DSL - Experiment 5 Aim: Write Matlab Program To Study The Sampling & Reconstruction Process

This document contains a Matlab program to study the sampling and reconstruction process. It defines a message signal as a sine wave, samples the signal at regular intervals to get sample values, and then reconstructs the continuous signal from the samples using sinc interpolation. The program plots the original message signal, sampled signal, and reconstructed signal to analyze the sampling and reconstruction process.

Uploaded by

chucha
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

DSL - Experiment 5

Aim: Write Matlab program to study the Sampling & Reconstruction Process

A. SAMPLING

Matlab Code

%Defining message signal x(t)=mag*sin(2*pi*fm*t)


mag=2; %Magnitude of message signal
fm=100; %Frequency of message signal
tm=1/fm; %Time period of message signal in sec
n_cycles=4; %no. of cycles
t_time=n_cycles*tm; %Total duration of signal in sec
t=0:0.001:t_time; %Time interval for plotting
x=mag*sin(2*pi*fm*t); %message signal
subplot(3,1,1); %plotting message signal
plot(t,x);
title('Message signal')
xlabel('t (sec)');
ylabel('x(t)');

%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

subplot(3,1,2); %Plotting the samples


xaxis=0:1:(length(x_samples)-1);
stem(xaxis,x_samples,'filled','r');
title('Sampled signal')
xlabel('n^{th} sample');
ylabel('x_s(n)');
B. RECONSTRUCTION

𝑡
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)');

You might also like