Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
0 Scope
This lab will primarily focus on the properties of continuous and discrete-time signals
using digital computers and the Matlab software environment. A continuous-time signal takes
on a value at every point in time, whereas a discrete-time signal is only defined at integer
values of the “time” variable. Sampling is a process that continuous-time signals might
process with first approximating of discrete-time signals. A proper selection of the spacing
between samples is crucial for an efficient and accurate approximation of a continuous-time
signal. Excessively close spacing will lead to too much data, whereas excessively distant
spacing will lead to a poor approximation of the continuous-time signal.
1.2 Objective
The purpose of this lab is to illustrate the properties of continuous and discrete-time
signals using MATLAB software environment.
1.3 Equipment
MATLAB software
1.4 Theoretical background
[2]
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 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.[3]
Procedure:
1. MATLAB is started and the commands in Listing 1 are typed.
Listing 1:
n=0:2:60;
y=sin(n/6);
subplot(3,1,1)
stem(n,y)
Listing 2:
n1 = 0:2:60;
z = sin (n1/6);
subplot(3,1,2)
plot(n1,z)
n2 = 0:10:60;
w = sin(n2/6);
subplot(3,1,3)
plot(n2,w)
Procedure:
1. The amplitude is set to 1 Vp-p and the fundamental frequency is applied for fl=
1000Hz.
2. A signal defined as x(t) = cos (21000t) is considered.
3. In order to generate the signal, sampling frequency is applied for fs = 8000 Hz.
MATLAB command to generate the signal is shown in Listing 3.
Listing 3:
clear
clc
clf
t=[0:ts:N*ts];
x=A*cos (2*pi*fl*t);
% continuous-time signal
figure(1); subplot(2,1,1);plot(t,x);
title('plot of a cosine waveform');
ylabel('amplitude');xlabel('time(s)');
% discrete-time signal
figure(1);subplot(2,1,2);stem(x);
title('plot of cosine waveform');
ylabel('Amplidtude');xlabel('sample');
Procedure:
a) The following two continuous-time functions are plotted over the specified intervals.
A separate .m-function is written if necessary. The subplot command is used to put
both plots in a single figure, and the horizontal axes are labeled.
sinc(t) in [-10, 10]
rect(t) in [-2, 2]
*The function rect(t) may be computed in Matlab by using Boolean commands. For example,
if t = -10:0.1:10, then y = rect(t) may be computed using the matlab command y =
(abs(t)<=0.5).
b) An .m-script file is written to stem the following discrete-time function for a = 0.8, a
= 1.0 and a = 1.5. The subplot command is used to put all three plots in a single
figure.
an(u(n) - u(n - 10)) in [-20, 20]
c) An .m-script file is written to stem the following discrete-time function for a = 0.8, a
= 1.0 and a = 1.5. The subplot command is used to put all three plots in a single
figure.
ancos(n) u(n) with = /4 in [-1, 10]
*The unit step function y = u(n) may be computed in MATLAB using the command y =
inline(‘n>=0’, ‘n’), where n is a vector of values of the independent variable.
Procedure:
1. The convolution is carried out by a Discrete Transfer Function object. The program in
Listing 4 are typed into a file named convo.m
Listing 4:
x=[0 1 1 1 1 1 1 1 1 1 1 1 1 1];
h=[1 0.5 0.25 0.125 0.0625];
y=conv(x,h);
nz=10;
ly=length(y)+ nz;
xz=[x,zeros(1,ly-length(x))];
hz=[h,zeros(1,ly-length(h))];
yz=[y,zeros(1,nz)];
nn=0:ly-1;
subplot(3,1,1),stem(nn,xz,'filled'),axis([0 25 0 2]),
ylabel('x(nT)'), grid on
subplot(3,1,2),stem(nn,hz,'filled'), axis([0 25 0 2]),
ylabel('h(nT)'), grid on
subplot(3,1,3),stem(nn,yz,'filled'),axis([0 25 0 3]),
xlabel('Sample Index-n')
ylabel('y(nT)'), grid on
1.6 Result and analysis
Question 1: Explain the effect of each command in Listing 1. You may need to draw,
sketch or print out any figures graphs in your explanation.
n = 0:2:60; the time start with 0 and end with 60 with intervals of size 2.
y = sin(n/6); displaying discrete time signal.
subplot(3,1,1) breaking the figure window into 3 by 1 matrix of small axes.
stem(n,y) plot the data sequence of y at the specified values of n.
The plot in Listing 1 shows the discrete-time signal formed by computing the values
of the function sin(t/6) at points which are uniformly spaced at intervals of size 2. Notice that
while sin(t/6) is a continuous-time function, the sampled version of the signal, sin(n/6), is a
discrete-time function.
n1 = 0:2:60; the time start with 0 and end with 60 with intervals of size 2.
z = sin(n1/6); displaying continuous time signal.
subplot(3,1,2) breaks the figure window into 3 by 1 matrix of small axes.
plot(n1,z) plot the data sequence of z at the specified values of n1.
n2 = 0:10:60; the time start with 0 and end with 60 with intervals of size 10.
w = sin(n2/6); displaying continuous time signal.
subplot(3,1,3) breaks the figure window into 3 by 1 matrix of small axes.
plot(n2,w) plot the data sequence of w at the specified values of n2.
Both the graph produced is continuous waveform. The first graph is smoother if
compared with second graph. The first graph has only 2 intervals whereas the second graph
has 10 intervals.
clear
clc
clf
t=[0:ts:N*ts];
x=A*cos (2*pi*fl*t);
% continuous-time signal
figure(1); subplot(2,1,1);plot(t,x);
title('plot of a cosine waveform');
ylabel('amplitude');xlabel('time(s)');
clear
clc
clf
N=35; % calculated around 0-35 sample of signal
A=4; % Amplitude of signal
fl=2000; % signal frequency
fs=8000; % sampling frequency
ts=1/fs; % sampling interval
t=[0:ts:N*ts];
x=A*cos (2*pi*fl*t);
% continuous-time signal
figure(1); subplot(2,1,1);plot(t,x);
title('plot of a cosine waveform');
ylabel('amplitude');xlabel('time(s)');
Question 7: Write the commands (.m files) you used in solving the problems of Special
Functions.
Question 8: Plot manually the result you obtained.
a)
A=1;
fs=8000;
ts=1/fs;
t1=-10*pi:ts:10*pi;
y1=A*sinc(t1);
subplot(3,1,1)
plot(t1,y1)
title('plot of a continuous-time waveform');
ylabel('Amplitude'); xlabel('time(s)');
t2=-2:ts:2;
y2= A*(abs(t2)<=0.5);
subplot(3,1,2)
plot(t2,y2)
title('plot of a continuous-time waveform');
ylabel('Amplitude'); xlabel('time(s)');
Figure 1.4: show the graph special function for sinc[-10π,10π] and rect[-2,2].
For the upper graph, the waveform has reached a maximum peak of amplitude 1 in the
interval of 0. The sinusoidal waveform is decreased as the time increased for the positive side
and decreased for the negative side. For the lower graph, the amplitude of 1 is shown in the
interval of -2 to -0.5 and from 0.5 to 2 while the amplitude 0 is in the interval of -0.5 and 0.5.
The shown graph is due to the sampling frequency.
b)
when a=0.8:
u=inline('n>0','n');
m=(-20:1:20);
z=0.8.^m;
subplot(5,1,1);
stem(m,z);
n=-20:1:20;
subplot(5,1,2);
stem(n,u(n));
subplot(5,1,3);
stem(n,u(n-10));
subplot(5,1,4);
stem(n,(u(n)-u(n-10)));
subplot(5,1,5);
stem(n,0.8.^n.*(u(n)-u(n-10)));
Figure 1.5: Show the graph special function for 𝑎𝑛 (𝑢(𝑛) − 𝑢(𝑛 − 10)𝑖𝑛 [−20,20] when
a=0.8.
For the first graph, the discrete-time waveform is decreased steadily from 100 to 0 in the
range of -20 till 0. For the second graph, the waveform starts in the interval of 0 till 20 with
amplitude of 1. For the third graph, the waveform is shifted to the right by the interval of 10.
The waveform starts in the interval of 10 till 20 with the amplitude of 1. For the fourth graph,
the waveform with the amplitude of 1 is shown in the interval of 0 till 10. This is due to the
subtraction of second graph to the third graph. For the last graph, the waveform is decreased
steadily from the amplitude of 1 to 0 in the interval of 0 till 10. This is combination of first
graph with the fourth graph.
when a=1.5:
u=inline('n>0','n');
m=(-20:1:20);
z=1.5.^m;
subplot(5,1,1);
stem(m,z);
n=-20:1:20;
subplot(5,1,2);
stem(n,u(n));
subplot(5,1,3);
stem(n,u(n-10));
subplot(5,1,4);
stem(n,(u(n)-u(n-10)));
subplot(5,1,5);
stem(n,1.5.^n.*(u(n)-u(n-10)));
Figure 1.6: Show the graph special function for 𝑎𝑛 (𝑢(𝑛) − 𝑢(𝑛 − 10)𝑖𝑛 [−20,20] when
a=1.5.
when a=1.0:
u=inline('n>0','n');
m=(-20:1:20);
z=1.0.^m;
subplot(5,1,1);
stem(m,z);
n=-20:1:20;
subplot(5,1,2);
stem(n,u(n));
subplot(5,1,3);
stem(n,u(n-10));
subplot(5,1,4);
stem(n,(u(n)-u(n-10)));
subplot(5,1,5);
stem(n,1.0.^n.*(u(n)-u(n-10)));
Figure 1.7: Show the graph special function for 𝑎𝑛 (𝑢(𝑛) − 𝑢(𝑛 − 10)𝑖𝑛 [−20,20] when
a=1.0.
c)
when a=0.8:
u=inline('n>0','n');
n=(-1:0.2:10);
subplot(5,1,1);
p=cos(n*pi/4);
stem(n,p);
subplot(5,1,2);
stem(n,u(n));
subplot(5,1,3);
q=p.*u(n);
stem(n,q);
x=0.8.^n;
subplot(5,1,4);
stem(n,x);
subplot(5,1,5);
stem(n,x.*q);
𝜋
Figure 1.8: Show the graph special function for 𝑎𝑛 cos(𝜔𝑛) 𝑢(𝑛)𝑤𝑖𝑡ℎ 𝜔 = 4 𝑖𝑛 [−1,10]
when a=0.8.
For the first graph, the waveform shown is a cosine waveform. The waveform in the
interval of -1 to 2 and from 6 to 10 is in positive side while in the interval of 2 to 6, it is in the
negative side. For the second graph, the waveform starts in the interval of 0 till 10 with
amplitude of 1. For the third graph, it is a sinusoidal waveform with the positive side on the
range of 0 to 2 and 6 to 10 meanwhile the negative side is on the range of 2 to 6. It is the
combination of first and second graph. For the fourth graph, the waveform is decreased
steadily from 1 to 0 in the range of -1 to 10. For the last graph, it is also a sinusoidal
waveform with the positive side on the interval of 0 till 2 and 6 till 10 but the negative side is
on the interval of 2 till 6. This is combination of third graph with the fourth graph.
when a=1.5:
u=inline('n>0','n');
n=(-1:0.2:10);
subplot(5,1,1);
p=cos(n*pi/4);
stem(n,p);
subplot(5,1,2);
stem(n,u(n));
subplot(5,1,3);
q=p.*u(n);
stem(n,q);
x=1.5.^n;
subplot(5,1,4);
stem(n,x);
subplot(5,1,5);
stem(n,x.*q);
𝜋
Figure 1.9: Show the graph special function for 𝑎𝑛 cos(𝜔𝑛) 𝑢(𝑛)𝑤𝑖𝑡ℎ 𝜔 = 4 𝑖𝑛 [−1,10]
when a=1.5.
when a=1.0:
u=inline('n>0','n');
n=(-1:0.2:10);
subplot(5,1,1);
p=cos(n*pi/4);
stem(n,p);
subplot(5,1,2);
stem(n,u(n));
subplot(5,1,3);
q=p.*u(n);
stem(n,q);
x=1.0.^n;
subplot(5,1,4);
stem(n,x);
subplot(5,1,5);
stem(n,x.*q);
𝜋
Figure 1.10: Show the graph special function for 𝑎𝑛 cos(𝜔𝑛) 𝑢(𝑛)𝑤𝑖𝑡ℎ 𝜔 = 4 𝑖𝑛 [−1,10]
when a=1.0.
_____________________________________________________________________
________________________________________________
A. control data
B. display data
C. manipulate that carried information
D. store information
5. Relation between input and output can be expressed by y[n] x[n] * h[n] . The
equation is called
A. Convolution method
B. Convolution of Integral
C. Convolution of Sum
D. Multiply convolution
1.7 Conclusion
The objective of the lab which is to illustrate the properties of continuous and discrete
time signals using digital computers and the MATLAB software is achieved. The continuous
signal and discrete signal are actually the same. Continuous signal shows the output as a
waveform whereas a discrete signal shows the output in point form which produces a
waveform.
1.8 Recommendation
For future, the lab sheet provided should be more students friendly where the hints
given should be more clear and understandable when a certain coding is needed to be
produced by the students.
Reference