Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

E336 Biomedical Signal Processing

Worksheet for Problem 03 : Remove The Spikes


1. We have already learnt that a DAQ card will convert an analog signal to a dig
ital signal. Why do we need a digital signal rather than a continuous signal for
further processing? Discuss the difference between a discrete signal and a digi
tal signal in your team.
2. As you have learnt, mathematically, we can represent an analog signal by a fu
nction, such as y = sin (t). How can you represent a discrete signal?
x(n) = { ; ; }

3. A unit sample sequence (unit impulse) ((n) is useful in representing a discre


te time sequence. ((n) is defined as

(a) Based on the definition above, complete the following table, and sketch ou
t the ((n) sequence for n = - 5 to 6.
0n1236(-(n)
-1
-2
-3
-4 5
(b) ((n-k) can be expressed by

Given different k, ((n-k) forms different sequences, such as ((n-1) when k = 1,


((n-2) when k = 2, etc. Complete the following table, and sketch out ((n-k), i.e
, ((n-2), ((n-5), ((n+1), ((n+3) separately.
n1(23456-(n+3)
-1
-2
-3
0-4 5
(n-2)
(n-5)
(n+1)

(c) Compare the plots you have sketched in (a) and (b). What are the differe
nces between the plots in terms of position and amplitude? Can you specify the r
elation of the plots of ((n), ((n-2), and ((n+1)?
4. Now let s investigate how to represent a discrete time signal.
(a) One way is to represent a discrete time signal by the combination of unit im
pulse sequences. For example, given a discrete time signal x(n) represented by
the following equation:
x(n) = ((n) +1.5 ((n-1) - 2.5 ((n-2) - ((n-5).
Based on the definition of ((n), complete the following table, and sketch out
x(n).
n-123456x1.5
-1
0-2
-2.5 3
(n)
(b) Another way is to represent a discrete signal by a number sequence. For exam
ple, if a discrete time signal y(n) has value 0 when n = 0 (i.e., y(0) = 0), val
ue 0.8 when n = 1 (i.e., y(1) = 0.8), value 2 when n = 2 (i.e., y(2) = 2), value
-1 when n = 3 (i.e., y(3) = -1) etc, then y(n) can be represented as
y(n) = {0, 0.8,2, -1, .} .
(Arrow indicates where n=0)
Can you represent the x(n) acquired in 4(a) by this method?
X = {1, 1.5, -2.5, 0, 0, -1}

(c) Given a sequence w(n) = {2, 0, 3, -6, 0, 2, -1 } (for n = 0 ~ 6), this m


eans when n = 0, w(0) = 2 and when n = 1, w(1) = 0, etc.
i) List out all the values of w(n) for n = 0~6.
w(n) = {2, 0, 3, -6, 0, 2}

ii) Sketch out w(n).



iii) Based on the plot of w(n) obtained in (ii), can you represent w(n) using co
mbinations of unit impulse sequence ((n-k), i.e., ((n), ((n-1), ((n-2), etc as i
n Question 4(a)? Write it out.
W(n) = 2((n) + 3( (n-2) - 6((n -3) + 2((n-5) -1((n-6)

(d) To generalize the results of (c), given a sequence x(n) = { a0,


a1, a2,. . . , ai, . . , ak }, how can you represent x(n) as a sum of
((n), ((n-1), ((n-2), ((n-k)?
x(N) = { a0((N) + a1((n-1) + a2((n-2) + ai((n-i) + ak((n-k) }

5. (a) Given x(n) = ((n), y(n) = { 4, 0, -2, -3, 1} for n = 0~4, can you repr
esent y(n) by ((n)? Can
you represent y(n) by x(n)?
[Hint : Represent y(n) by ((n) first, see Q.4.d. Then replace (
(n) with x(n) ]
y(n)= 4( (n) -2( (n-2) -3( (n-3) + 1( (n-4)
x(n) = {a0((n) + a1((n-1) + a2((n-2) + a3((n-3) + a4((n-4)}

(b) A discrete-time (DT) system outputs a discrete time signal, y(n)


, when a discrete-time signal, x(n), is applied at the input.

Usually, the output of the system, y(n), is a linear function of the input of th
e system, x(n), i.e.
y(n) = f{x(n)}
f { } is often in the form of:
y(n) = aox(n) + a1x(n-1) + a2x(n-2) + .+ b1y(n-1) + b2y(n-2) +
What is the name of this kind of equation which gives the relationship between t
he discrete output, y(n), and discrete input, x(n)?
Difference Equation
(c) Analyze the equation y(n) = aox(n) + a1x(n-1) + a2x(n-2) + .+ b1y(n-1) +
b2y(n-2) + . What are the basic mathematical operations involved in the equation?
Addition, Multiplication

6.
(a) The following mathematical operators are used as the basic building blocks
of a discrete time system, can you find out the name of each operator (from A th
rough D)? Explain their functions respectively.

Operator A - ADDER

y = x(n) + w(n)
Operator B - MULTIPLIER

y(n) = G? x(n),
Operator
where
C G is-aUNIT
constant
DELAY

Operator D y(n)-=UNIT
x(n-1)
FASTER

y(n) = x(n+1)

(b) Can you write the difference equation represented by the following digita
l network block diagram?
y(n) = [x(n-1) * 2. x(n)] + [x(n-2) * 3. x(n)] + [x(n)]
(c) Draw the digital network block diagrams using the basic operation blocks to
describe the following difference equations:
(i) y(n) = 2x(n) + 1.5x(n-1) + 5x(n-2)
(ii) y(n) = x(n) + 0.6 y(n-1)

7. Simulink is an extension to MATLAB that allows engineers to rapidly and accur


ately build a signal processing model using block diagram notations.
Using MATLAB Simulink, open the Simulink file E336_P3_1.mdl and observe the 3 basi
c operations on discrete time signals addition, multiplication and delay as show
n in Fig.1.
(Hint: In MATLAB command window, type in simulink . Then go to file in the simulink
tool bar, and select the file you want to open.).

Fig.1

8. A Linear System obeys the superposition principle. Suppose input x1(n) produc
es output y1(n), input x2(n) produces output y2(n), and given a linear combinati
on of inputs x3(n) = a x1(n) + b x2(n), produces an output y3(n).

If y3(n) = a y1(n) + b y2(n), then this is a linear system. If y3(n) ? a y1(n) +
b y2(n), then this is a non-linear system.
Based on the definition above, classify the following systems as linear or non-l
inear.
[ Hints: Assume you are given x1, x2,and x3 = x1 + x2; calculate y1, y2, y3 bas
ed on the equations given; check whether y3 = y1 + y2 ]
i) y(n) = 2x(n) + 5x(n-2) [Linear]
ii) y(n) = 2 + x(n) [Non Linear]
9. Suppose a system outputs y(n) when x(n) is applied to it. When a time shifted
version of x(n), i.e., x(n-m) is applied, it produces an output y(n-m). Then it
is a time-invariant system.
Given that x(n) = 2((n), classify the following systems as time invariant or non
-time invariant. Illustrate your answers using discrete time domain diagrams.
time-invariant system is one whose output does not depend explicitly on time. Th
at is, treating time as the independent
[ Hints: calculate x(n), x(n-1), y(n), y(n-1), then compare the time shifts ]

i) y(n) = x(n) + 2x(n-1) [time-invariant]

ii) y(n) = x(2n)

10. The moving average filter is one of the most common filters in digital signa
l processing (DSP). In spite of its simplicity, the moving average filter is opt
imal for a common task: reducing random noise while retaining a sharp step respo
nse. This makes it the premier filter for discrete time signals. As the name imp
lies, the moving average filter operates by averaging a number of points from th
e input signal to produce each point in the output signal. Now, let s investigate
how an Averager works.
Given y(n) = [ x(n) + x(n-1) + x(n-2)] / 3,
a) Calculate y(n) for n = 0 to 10. Fill the table below. Sketch out x(n).
b) Use MATLAB to plot both y(n) and x(n). Comment on your observations.
n624387y9x-.333
-1
x(n)
510x(n-1)
8.333
7.333 02
(n-2)
(n)
.33
.067

11. A moving average filter can be modeled mathematically as shown in equation (


1)

(1)

M is the number of input samples you want your filter to take in for averaging,
x [ ] is the input sequence. Given M = 3, equation (1) will be:

Design a moving average filter with M = 3 by using the 3 basic operations of Sim
ulink.
(a) Open the Simulink file E336_P3_2.mdl .
(b) Connect the block diagrams according to the difference equations


(c) Run the model and observe the results by double clicking the x(n) scope an
d y(n) scope . What observations can you make?

x(n) scope:

y(n)scope:


12. Now refer to today s problem. Based on what you have learnt regarding block di
agrams and moving average filter, can you design a digital network to remove the
spike noise? Open the Simulink file E336_P3_3.mdl , modify and run it. Comment on
your observations.
(Using M = 8)

Going further
Use Simulink to draw the digital network block diagram to represent the followin
g difference equation. If x(n) is an impulse sequence, observe and interpret the
output y(n).
y(n) = x(n) + 2x(n-1) + 5x(n-2) + 8x(n-3)

SCHOOL OF
ENGINEERING

Page  PAGE 8 of  NUMPAGES 13

You might also like