Aim:
To perform the sampling operation on the message signal with sampling frequencies
and reconstruction of message signal.

Algorithm:
1. Clear command window
2. Clear all variables in workspace window
3. Close all the files in current folder window
4. Generate the sinusoidal expression (sig1) with frequency (f) to
200/300/400/500/600 Hz and time (t) from 0 to 10/f in interval of 10−4 sec
5. Generate the expression for sampled signal (sig) with time (t2) from 0 to 10/f
in interval of sampling frequency (Fs) of 2500/3500/4500/5500/6500 Hz
6. Generate the expression for reconstruction of sinusoidal wave from samples
using “sinc” function
A. Determine zeros of length of time duration of original signal to a variable (xr)
B. Create a for loop (k) from 1 to length of length of time duration of original signal
C. Create a for loop (p) from 1 to length of length of sampled signal
D. Assign the variable (Tr) as 10-4
E. Generate expression
xr(k)=xr(k)+xb(p)*sinc (((k-1)*Tr-(p1)*Ts)/Ts )
7. Plot all the graphs in a single figure window with titles “Original Sinusoidal signal”,
“Sampled signal”, “Reconstructed signal” to the graphs
8. Label the plots on x-axis and y-axis.

Program:
clc;
clear all;
close all;

%generating message signal with frequency of 500 Hz
fm=500;
t=25/fm;
ti=0:0.0001:t;
x=sin(2*pi*fm*ti);
figure
subplot(3,1,1);
plot(ti,x);
xlabel('time period(sec)');
ylabel('Amplitude (volts)');
title('Input signal');

%sampling the message signal with frequency of 5000 Hz
fs=5000;
ts=1/fs;
t1=0:ts:t;
x1=sin(2*pi*fm*t1);
subplot(3,1,2);
stem(t1,x1);
xlabel('sampling period (n)');
ylabel('Amplitude (volts)');
title('sampled signal');

%Reconstruction of message signal using sincfuction
xr=zeros(length(ti))
fori=1:length(ti)
for j=1:length(x1)
tr=10^-4;
xr(i)=xr(i)+x1(j)*sinc(((i-1)*tr-(j-1)*ts)/ts);
end
end
subplot(3,1,3)
plot(ti,xr);
xlabel('time period(sec)');
ylabel('Amplitude (volts)');
title('reconstructed signal')