Sei sulla pagina 1di 20

1.

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.1 Problem statement

 How to use MATLAB software to illustrate the properties of continuous and


discrete-time signals?

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

A continuous signal or a continuous-time signal is a varying quantity (a signal) whose


domain, which is often time, is a continuum (e.g., a connected interval of the reals). That is,
the function's domain is an uncountable set. The function itself need not be continuous. To
contrast, a discrete time signal has a countable domain, like the natural numbers.
A signal of continuous amplitude and time is known as a continuous time signal or an analog
signal. This (a signal) will have some value at every instant of time. The electrical signals
derived in proportion with the physical quantities such as temperature, pressure, sound etc.
are generally continuous signals. The other examples of continuous signals are sine wave,
cosine wave, triangular wave etc. Some of the continuous signals.
The signal is defined over a domain, which may or may not be finite, and there is a functional
mapping from the domain to the value of the signal. The continuity of the time variable, in
connection with the law of density of real numbers, means that the signal value can be found
at any arbitrary point in time.
In many disciplines, the convention is that a continuous signal must always have a finite
value, which makes more sense in the case of physical signals.
For some purposes, infinite singularities are acceptable as long as the signal is integrable over
any finite interval (for example, the signal is not integrable, but is).
Any analogue signal is continuous by nature. Discrete signals, used in digital signal
processing, can be obtained by sampling and quantization of continuous signals.
Continuous signal may also be defined over an independent variable other than time. Another
very common independent variable is space and is particularly useful in image processing,
where two space dimensions are used.[1]
Convolution is a mathematical operation on two functions f and g, producing a third
function that is typically viewed as a modified version of one of the original functions, giving
the area overlap between the two functions as a function of the amount that one of the
original functions is translated. Convolution is similar to cross-correlation. It has applications
that include probability, statistics, computer vision, image and signal processing, electrical
engineering, and differential equations.
For complex-valued functions f, g defined on the set Z of integers, the discrete
convolution of f and g is given by:

[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]

Discrete sample signal


1.5 Methodology

TASK 1: DISPLAYING CONTINUOUS-TIME AND DISCRETE-TIME SIGNALS IN


MATLAB

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)

2. MATLAB commands are used in Listing 2 to generate two continuous-time plots of


the signal sin (t/6).

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)

TASK 2: GENERATING THE CONTINUOUS-TIME AND DISCRETE-TIME


SIGNALS WITH SAMPLING FREQUENCY

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 (21000t) 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

N=35; % calculated around 0-35 sample of signal


A=1; % Amplitude of signal
fl=1000; % 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)');

% discrete-time signal
figure(1);subplot(2,1,2);stem(x);
title('plot of cosine waveform');
ylabel('Amplidtude');xlabel('sample');

TASK 3: SPECIAL FUNCTIONS

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.

TASK 4: DISCRETE-TIME CONVOLUTION

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.

Figure 1.1: show the graph of discrete-time signal.

Question 2: From your observation, is Listing 1 generating a continuous-time signal or


discrete-time signal? Please explain.

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.

Question 3: Explain the effect of each command above.

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.

Question 4: Plot the graph obtained from the commands above

Figure 1.2: show the graph of continuous-time signal.

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.

Question 5: Plot the graph obtained from the commands in Listing 3.


Figure 1.3: show the graph of continuous-time and discrete-time signal.

Question 6: Write a program in MATLAB for approximating the following


continuous-time periodic signals:

 Sinusoidal waveform of amplitude 3 V p-p, fundamental frequency 1500 Hz, and


sampling frequency 8000 Hz.

clear
clc
clf

N=35; % calculated around 0-35 sample of signal


A=3; % Amplitude of signal
fl=1500; % 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)');

 Sinusoidal waveform of amplitude 4 V p-p, fundamental frequency 2000 Hz, and


sampling frequency 8000 Hz.

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.

Question 9: Calculate the above convolution manually.

Question 10: Plot manually the result you obtained.


Figure 1.11: show the graph of discrete-time signal before and after convolution.

Answer all questions.

1. Please distinguish between Discrete and Continues-time signals.


_____________________________________________________________________

_____________________________________________________________________

________________________________________________

2. What is convolution of a signal?

A. To filter the components of the signal.


B. To masking the signal.
C. To multiply two or more signals.
D. To magnify the signal.
3. Deterministic signals are the signals whose characteristics are well known and
completely specified for all instants of time. The example of deterministic signal
are shown below EXCEPT

A. unit step function


B. unwanted disturbances in a system
C. sine wave
D. cosines wave

4. The job of the “System”is often to

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

[1] [Online] viewed 2013 April 21, Available:


http://en.wikipedia.org/wiki/Continuous_signal
[2] [Online] viewed 2013 April 21, Available:
http://en.wikipedia.org/wiki/Convolution
[3] [Online] viewed 2013 April 21, Available:
http://en.wikipedia.org/wiki/Discrete_signal

Potrebbero piacerti anche