You are on page 1of 11

BIOLOGICAL SIGNALS PROCESSING

PRACTICE #1: SAMPLING THEOREM

GENERAL PURPOSE
Apply the sampling theorem to a signal, in this case to both a sine wave and a voice
signal, to observe its behavioral change at different sampling frequencies.

INTRODUCTION
The Nyquist Theorem, also known as the sampling theorem, is a principle that
engineers follow in the digitization of analog signals. For analog-to-digital
conversion (ADC) to result in a faithful reproduction of the signal, slices,
called samples, of the analog waveform must be taken frequently. The number of
samples per second is called the sampling rate or sampling frequency.
Any analog signal consists of components at various frequencies. In practice,
analog signals usually have complex waveforms, with components at many
frequencies. The highest frequency component in an analog signal determines
the bandwidth of that signal. The higher the frequency, the greater the bandwidth, if
all other factors are held constant.
According to the Nyquist Theorem, the sampling rate must be at least 2fmax, or
twice the highest analog frequency component. The sampling in an analog-todigital converter is actuated by a pulse generator (clock). If the sampling rate is
less than 2fmax, some of the highest frequency components in the analog input
signal will not be correctly represented in the digitized output. When such a digital
signal is converted back to analog form by a digital-to-analog converter, false
frequency components appear that were not in the original analog signal. This
undesirable condition is a form of distortion called aliasing.
Suppose we are sampling a sine wave. If we sample at 1 time per cycle, we can
think it's a constant (figure 1.1).

Figure 1.1
If we sample at 1.5 times per cycle, we can think it's a lower frequency sine wave
(figure 1.2). If we sample at twice the sample frequency, i.e Nyquist Rate, we start
to make some progress. In this case (at these sample points) we get a saw tooth
wave that begins to start crudely approximating a sine wave (figure 1.3).

Figure 1.2

Figure 1.3

For lossless digitization, the sampling rate should be at least twice the maximum
frequency responses (figure 1.4).

Figure 1.4. Sampling at many times per cycle.

DEVELOPMENT
First part
Using MATLAB, we generated a sine wave at 50 Hz using sampling frequencies
from 1000 to 50 Hz every 50 Hz. We sketched 0.08 seconds of each signal to better
observe changes.
The code in MATLAB for part one:
A=1; %For an amplitude of 1
f=50; % and a frecuency of 50
% Determining each graphs sampling
frequency
t1=[0:1/1000:0.08];
y1=A*sin(2*pi*f*t1);
t2=[0:1/950:0.08];
y2=A*sin(2*pi*f*t2);
t3=[0:1/900:0.08];
y3=A*sin(2*pi*f*t3);
t4=[0:1/850:0.08];
y4=A*sin(2*pi*f*t4);
t5=[0:1/800:0.08];
y5=A*sin(2*pi*f*t5);
t6=[0:1/750:0.08];
y6=A*sin(2*pi*f*t6);
t7=[0:1/700:0.08];
y7=A*sin(2*pi*f*t7);
t8=[0:1/650:0.08];
y8=A*sin(2*pi*f*t8);
t9=[0:1/600:0.08];
y9=A*sin(2*pi*f*t9);
t10=[0:1/550:0.08];
y10=A*sin(2*pi*f*t10);
t11=[0:1/500:0.08];
y11=A*sin(2*pi*f*t11);
t12=[0:1/450:0.08];
y12=A*sin(2*pi*f*t12);
t13=[0:1/400:0.08];
y13=A*sin(2*pi*f*t13);
t14=[0:1/350:0.08];
y14=A*sin(2*pi*f*t14);
t15=[0:1/300:0.08];
y15=A*sin(2*pi*f*t15);
t16=[0:1/250:0.08];

figure(3)
subplot (4,1,1);
plot(t9,y9)
title ('Fs = 600')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,2);
plot(t10,y10)
title ('Fs = 550')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,3);
plot(t11,y11)
title ('Fs = 500')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,4);
plot(t12,y12)
title ('Fs = 450')
xlabel('time (s)')
ylabel('[y]')
figure(4)
subplot (4,1,1);
plot(t13,y13)
title ('Fs = 400')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,2);
plot(t14,y14)
title ('Fs = 350')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,3);
plot(t15,y15)

y16=A*sin(2*pi*f*t16);
t17=[0:1/200:0.08];
y17=A*sin(2*pi*f*t17);
t18=[0:1/150:0.08];
y18=A*sin(2*pi*f*t18);
t19=[0:1/100:0.08];
y19=A*sin(2*pi*f*t19);
t20=[0:1/50:0.08];
y20=A*sin(2*pi*f*t20);
%Plotting and subplotting each
graph
figure(1)
subplot (4,1,1);
plot(t1,y1)
title ('Fs = 1000')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,2);
plot(t2,y2)
title ('Fs = 950')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,3);
plot(t3,y3)
title ('Fs = 900')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,4);
plot(t4,y4)
title ('Fs = 850')
xlabel('time (s)')
ylabel('[y]')
figure(2)
subplot (4,1,1);
plot(t5,y5)
title ('Fs = 800')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,2);
plot(t6,y6)
title ('Fs = 750')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,3);
plot(t7,y7)
title ('Fs = 700')
xlabel('time (s)')

title ('Fs = 300')


xlabel('time (s)')
ylabel('[y]')
subplot (4,1,4);
plot(t16,y16)
title ('Fs = 250')
xlabel('time (s)')
ylabel('[y]')
figure(5)
subplot (4,1,1);
plot(t17,y17)
title ('Fs = 200')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,2);
plot(t18,y18)
title ('Fs = 150')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,3);
plot(t19,y19)
title ('Fs = 100')
xlabel('time (s)')
ylabel('[y]')
subplot (4,1,4);
plot(t20,y20)
title ('Fs = 50')
xlabel('time (s)')
ylabel('[y]')

ylabel('[y]')
subplot (4,1,4);
plot(t8,y8)
title ('Fs = 650')
xlabel('time (s)')
ylabel('[y]')

Part 2
In class we acquired a series of voice samples at different sampling frequencies of
44100 Hz, 22000 Hz, 11000 Hz and 5000 Hz. These signals were plotted as well to
compare them.
The code in MATLAB for part 2:
[y,Fs]=audioread('F:\actual\01.wav');
[y2,Fs2]=audioread('F:\actual\02.wav');
[y3,Fs3]=audioread('F:\actual\03.wav');
[y4,Fs4]=audioread('F:\actual\04.wav');
figure(1)
subplot(411)
plot(y)
title ('Fs = 44100')
xlabel('time (s)')
ylabel('[y]')
subplot(412)
plot(y2)
title ('Fs = 22000')
xlabel('time (s)')
ylabel('[y]')
subplot(413)
plot(y3)
title ('Fs = 1100')
xlabel('time (s)')
ylabel('[y]')
subplot(414)
plot(y4)
title ('Fs = 500')
xlabel('time (s)')
ylabel('[y]')

RESULTS
Part one

Figure 2.1 Sine wave signal at sampling frequencies from 1000 Hz to 850 Hz

Figure 2.2 Sine wave signal at sampling frequencies from 800 Hz to 650 Hz

Figure 2.3 Sine wave signal at sampling frequencies from 600 Hz to 450 Hz

Figure 2.4 Sine wave signal at sampling frequencies from 400 Hz to 250 Hz

Figure 2.5 Sine wave signal at sampling frequencies from 200 Hz to 50 Hz

Part two

Figure 3.1. The voice signals acquired at different sampling frequencies.

CONCLUSIONS

In the first part of this practice, we observed the graphs of sine waves at different
sampling frequencies. In the second part we sketched voice signals in a similar
way. In both cases we can clearly see how the lowest sampling frequencies show
the most information loss, while at the highest sampling frequencies the signals
show less distortion. With this, we have proved the sampling theorem: at higher
sampling frequencies we can obtain a signal closer to the actual one. Yet, we need
to determine whether this is necessary, since this also means that more memory
will be needed, not to mention that in some cases the sampling frequency can be
lowered enough before observing any kind of distortion or significant information
loss.

REFERENCES

http://whatis.techtarget.com/definition/Nyquist-Theorem

https://www.cs.cf.ac.uk/Dave/Multimedia/node149.html

You might also like