Professional Documents
Culture Documents
Matlab Sampling
Matlab Sampling
AIM: To write a MATLAB program to sample the sinusoidal message signal at different sampling rate
and verify the Nyquist criteria. Also reconstruct the sampled signal using low pass filter (Using FDA Tools).
THEORY:
Sampling: Sampling is the process in which a continuous time signal is sampled by measuring its
amplitude at discrete instants.
Sampling Theorem: The Sampling Theorem states that a signal whose spectrum is band-limited to Fm
Hz can be reconstructed exactly (without error) from its samples taken uniformly at a frequency Fs ≥
2Fm (Samples per second).
In other words, the minimum sampling frequency is Fs = 2·Fm.
The frequency 2· Fm is called the Nyquist sampling rate.
The corresponding sampling interval Ts = 1/ (Fs) is called Nyquist interval.
MATLAB CODE:
clc
clear all
close all
fm=1
t=1:0.1:10
x=sin(2*pi*fm*t);
subplot(331)
plot(t,x)
title('x(t)')
xlabel('time')
ylabel('amplitude')
%undersampled
fs1=0.5*fm;
t1=0:0.1/fs1:10;
A=sin(2*pi*fm*t1);
subplot(332)
stem(t1,A)
title('undersampled')
xlabel('time')
ylabel('amplitude')
A1=filter(fm,1,A)
subplot(333)
plot(t1,A1)
title('reconstructed undersampled')
xlabel('time')
ylabel('amplitude')
%critically sampled
fs2=fm*2
t2=0:0.1/fs2:10
B=sin(2*pi*fm*t2)
subplot(334)
stem(t2,B)
title('critically sampled')
xlabel('time')
ylabel('amplitude')
B1=filter(fm,1,B)
subplot(335)
plot(t2,B1)
ylabel('amplitude')
%oversampled
fs3=fm*6
t3=0:0.1/fs3:10
C=sin(2*pi*fm*t3)
subplot(336)
stem(t3,C)
title('over sampled')
xlabel('time')
ylabel('amplitude')
C1=filter(fm,1,C)
subplot(337)
plot(t3,C1)
title('reconstructed oversampled')
xlabel('time')
ylabel('amplitude')
OUTPUT WAVEFORM:
CONCLUSION:
We have implemented the sampling of a sinusoidal signal at various sampling rates and verified
Nyquist theorem for sampling of signals through MATLAB code and have observed the waveforms
and have also reconstructed the original signal after sampling.