Sie sind auf Seite 1von 6

NEW ERA UNIVERSITY

College of Engineering and Technology


Department of Electronics Engineering

LABORATORY REPORT NO. 3


SAMPLING OF DISCRETE TIME SIGNALS IN MATLAB

NAME: LORENZANA, ERBEE STEPHANIE P. SCHEDULE: FRIDAY 1:00-4:00 PM

SECTION: 4ECE-B INSTRUCTOR: ENGR. ESMERALDA MANIQUIS

RATING
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

Exercise:
1. Write a comment which gives a brief description of the command beside each line of the program.
2. If you would alter the value of f or T, what would happen to your signal?

-The signal’s graphical representation would either become finer or coarser, and
the number of cycle may increase/decrease according to the graph it shown after
you input the change of codes.

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

clf; subplot(3,1,2); subplot(3,1,3)


t=0:.05:20; T=0.1; n =(0:T:20)';
f=1; n=0:T:20; xs =2*sin(2*pi*f*n);
xa=2*sin(2*pi*f*t); xs=2*sin(2*pi*f*n); t = linspace(0,20,1200)';
subplot(3,1,1) k=0:length(n)-1; ya = sinc((1/T)*t(:,ones(size(n))) -
plot(t,xa); stem(k,xs); (1/T)*n(:,ones(size(t)))')*xs;
grid; grid; plot(n,xs,'o',t,ya);grid;
xlabel('Time,msec'); xlabel('Time index n'); xlabel('Time, msec');
ylabel('Amplitude'); ylabel('Amplitude'); ylabel('Amplitude');
title('Continuous time signalx_{a} title('Discrete time signalx[n]'); title('Reconstructed Continuous
(t)'); axis([0 (length(n)-1) -4 4]) Time Signal y_{a}(t)');
axis([0 20 -4 4]) 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).
T=0.1;
f=1;
n=(0:T:10)';
Ys=sin(2*pi*f*n);
subplot(6,1,1);
stem(n,Ys);grid;
xlabel('n, 0.1 sampling interval');
ylabel('Amplitude');
title('Sampling Signal Representation y_{s}(n)');
t=linspace(0,10,1000)';
Yt=sin(2*pi*f*t);
subplot(6,1,2);
plot(n,Ys,'o',t,Yt);grid;
title('Sampling projected in the signal to be sampled');
xlabel('t,time');
ylabel('Amplitude');
Yc=sinc((1/T)*t(:,ones(size(n))) -(1/T)*n(:,ones(size(t)))')*Ys;
subplot(6,1,3);
plot(t,Yc);grid;
xlabel('t,time');
ylabel('Amplitude');
title('Reconstructed Continuous Time Signal y_{c}(t)');
n1=(0:.4:10)';
Ys1=sin(2*pi*f*n1);
subplot(6,1,4);
stem(n1,Ys1);grid;
xlabel('n, 0.4 sampling interval');
ylabel('Amplitude');
title('Sampling Signal Representation @ 0.4 interval y_{s}(n)');
subplot(6,1,5);
plot(n1,Ys1,'o',t,Yt);
title('Sampling projected in the signal to be sampled')
Yc1=sinc((1/T)*t(:,ones(size(n1))) -(1/T)*n1(:,ones(size(t)))')*Ys1;
subplot(6,1,6);
plot(t,Yc1);
xlabel('t,time');
ylabel('Amplitude');
title('Reconstructed Continuous Time Signal y_{c}(t)');

Das könnte Ihnen auch gefallen