You are on page 1of 8

New Era University

College of Engineering
And Technology

Activity #3
ECE474 Lab

Submitted by : Carlou Mark Castillo


Course/yr: BS-ECE/4thyr
Date: july 5 2013

Laboratory Experiment No. 03


Sampling of discrete time signals in MATLAB
Theory:
A discrete signal or discrete-time signal is a time series consisting of a sequence of qualities.
In other words, it is a type series that is a function over a domain of discrete integral.
Unlike a continuous-time signal, a discrete-time signal is a function of a continuous
argument; however, it may have been obtained by sampling from a continuous-time signal,
and then each value in the sequence is called a sample.
When a discrete-time signal obtained by sampling is a sequence corresponding to uniformly
spaced times, it has an associated sampling rate; the sampling rate is not apparent in the
data sequence, and so needs to be associated as a separate data item.
MATLAB CODE:
%Illustration of sampling process
%in the time domain
clf;
t=0:0.0005:1;
f=13;
xa=cos(2*pi*f*t);
subplot(2,1,1)
plot(t,xa);
grid;
xlabel('Time,msec');
ylabel('Amplitude');
title('Continuous time signalx_{a}(t)');
axis([0 1 -1.2 1.2])
subplot(2,1,2);
T=0.1;
n=0:T:1;
xs=cos(2*pi*f*n);
k=0:length(n)-1;
stem(k,xs);
grid;
xlabel('Time index n');
ylabel('Amplitude');
title('Discrete time signalx[n]');
axis([0 (length(n)-1) -1.2 1.2

Replace value of T and t (using 3 different values for each). Observe. Explain your
observation.

Understanding of aliasing effect of discrete time signals in MATLAB

Theory:
Aliasing is the phenomenon that results in a loss of information when a signal is
reconstructed from its sampled signal.
In Principle, the analogue can be reconstructed from the samples, provided that the
sampling rate is sufficiently high to avoid the problem called Aliasing.
Sinc
Syntax
y = sinc(x)
Description
sinc computes the sinc function of an input vector or array, where the sinc function is

This function is the continuous inverse Fourier transform of the rectangular pulse of width 2
and height 1.

y = sinc(x) returns an array y the same size as x, whose elements are the sinc function of
the elements of x.
The space of functions bandlimited in the frequency range is spanned by the infinite (yet
countable) set of sinc functions shifted by integers. Thus any such bandlimited function g(t)
can be reconstructed from its samples at integer spacings.

EXAMPLE:
n =(0:T:20)';

xs =2*sin(2*pi*f*n);
t = linspace(0,20,1200)';
T=0.1;
ya = sinc((1/T)*t(:,ones(size(n))) -(1/T)*n(:,ones(size(t)))')*xs;
plot(n,xs,'o',t,ya);grid;
xlabel('Time, msec');
ylabel('Amplitude');
title('Reconstructed Continuous Time Signal y_{a}(t)');
axis([0 20 -5 5]);

Exercise:
Using your previous knowledge in generating signal and sampling:

1. Create a sinusoidal sequence.

2. Illustrate the sampling process in the time domain.

3. Given that the sinc function is fundamental in the concept of reconstructing the
original continuous band limited signal from uniformly spaced samples of that signal,

prove that providing higher sampling rate greatly reduces aliasing. (Plot original
sinusoidal sequence and reconstructed sinusoidal sequence to visually compare the
result). Perform at least 3 sets.

You might also like