Title: MM3FC Mathematical Modeling 3 LECTURE 2
1MM3FC Mathematical Modeling 3LECTURE 2
- Times
- Weeks 7,8 9.
- Lectures Mon,Tues,Wed 10-11am, Rm.1439
- Tutorials Thurs, 10am, Rm. ULT.
- Clinics Fri, 8am, Rm.4.503
Dr. Charles Unsworth, Department of Engineering
Science, Rm. 4.611 Tel 373-7599 ext.
2461 Email c.unsworth_at_auckland.ac.nz
2This LectureWhat are we going to cover Why ?
- Discrete representation of continuous signals.
- (because this is how we digitize a signal)
- The Running Average Filter.
- (the simplest form of FIR filter)
- The General FIR filter.
- Impulse response of a filter.
- (a way to classify a filters characteristics)
3Continuous Discrete Signals
- Real world (analogue) signals are continuous
in time. - A continuous sinusoid x(t) is represented
- x(t) Acos(?t f)
- Any recorded signal is said to be discrete .
- A discrete (digital) signal is a snap-shot
xn of a continuous signal taken every (Ts)
secs. - xn x(t) with t nTs xn
Acos(?(nTs) f) - Where, (n) is an integer indicating the position
of the values in the sequence.
(2.1)
4Discrete-Time (Digital) Filters
- A digital filter
- - takes in a digital input signal xn.
- - alters it in some way, by an operation T .
- - And creates a digital output signal
yn Txn
5- A discrete-time (digital) signal is just a
sequence of numbers. - Thus, one can compute the values of the output
sequence yn from its input sequence xn. - Example 1. yn (xn)2
- The yn value is just the square of the xn
value. - (y1 x12, y2 x22, y3 x32, ,
yn xn2). - Example 2. yn maxxn, xn-1, xn-2
- The yn value is the largest of either xn,
xn-1 or xn-2. - Obviously, there are an infinite number of
systems that can be created.
6Example 3 The digital signal xn 1,2,3,4,5,
, N is passed through the filter yn (xn)2
. Determine the new filtered sequence yn.
7The Running Average filter
- A Finite Impulse Response (FIR) Filter takes a
finite length input sequence xn and produces a
finite length output sequence yn. - The simplest FIR filter is the running average
filter. It computes the moving average of two
or more consecutive numbers in a sequence. - The FIR filter is a generalisation of the idea
of the running average filter. - Example 4 A 3-point running average filter
creates 1 output value from - 3 consecutive input values divided by 3.
- y0 1/3( x0 x1 x2 )
- y1 1/3( x1 x2 x3 )
- Which generalises to
- yn 1/3( xn xn1 xn2 )
- This is known as a difference equation.
- It completely describes the entire output
signal for all indexed values inf to inf.
(2.2)
8- Lets consider a finite input signal xn which
is triangular in shape. - Which is the discrete-time (digital) sequence
- n nlt -2 -2 -1 0 1 2 3 4 5 ngt5
- xn 0 0 0 2 4 6 4 2 0 0
-
- Using the difference equation yn 1/3( xn
xn1 xn2 ) - We can create a difference table to calculate
the filters output.
9N nlt -2 -2 -1 0 1 2 3 4 5 ngt5 xn 0 0
0 2 4 6 4 2 0 0 yn 0 2/3 2 4
14/3 4 2 2/3 0 0
- Note How the output sequence is longer and
smoother than the input sequence. - Note That the output sequence starts before
the input sequence starts. This is because we are
using inputs from the present and future values.
10- A filter that uses future values of the
input is called non-causal. - (Non-causal systems cannot be used in real-time
applics. as the data is not available.) - A filter that uses only present and past
values is called a causal filter - Example 5 Write the difference equation for a
3-point running average causal filter. And
draw out its difference table. - Difference equation yn 1/3( xn xn-1
xn-2 ) - N nlt -2 -2 -1 0 1 2 3 4 5 6
7 ngt7 - xn 0 0 0 2 4 6 4 2 0 0 0
0 - yn 0 0 0 2/3 2 4 14/3
4 2 2/3 0 0 - The causal filter is also known as a backward
averager since all values are past and present. - When present and past values are used, in a
causal filter, the output does not start before
the input starts.
11Causal Uses present past and output doesnt
start before input
Non-causal Uses contains future and output
starts before input.
12- The support of a system is the set of values
where the sequence becomes non-zero.
- Thus, the support of the causal systems
- input is
- Finite in the range
- Thus, the support of the causal systems
output is - Finite in the range
- Whats the support for the non-causal systems
input and output ?
13The General FIR filter
- The running averager was a special case of the
FIR general difference equation - Namely, when M 2. This is the order of the
filter. - bk 1/3, 1/3, 1/3. Is the value of the filter
coefficient for each (k). - (If (bk) is not the same then we say that the
filter is a weighted running averager.) - The filter length is defined as L M1
no.filter coefficients. - There will be an interval of M samples at the
beginning where the sliding window engages with
the data using less than M1 points. - There will be an interval of M points at the
end where the sliding window dis-engages with the
data. - The ouput sequence can be as much as M samples
longer that the input.
(2.3)
Let k be ve for a non-causal.
14- Example 6 The FIR filter is completely defined
once the set of filter co-efficients bk are
known. - 0 1 2 3 k
- bk 3, -1, 2, 1
- The length of the FIR filter is L 4.
- The order of the filter is M L-1 3.
15Example 7 Compute the output yn for this FIR
filter in the form of a difference table for our
previous input sequence in Example 5.
16- In a real-time system, we dont have any data at
time nlt 0 ? - But our filter requires xn-1, xn-2 xn-3
to be known. - Intially, these values do not exist.
- The 1st Initial Rest Assumption helps us
alleviate this - Initial Rest Assumption
- 1) The input xn is assumed to be zero prior to
some starting point (n0) - i.e xn 0 for nlt n0
- We say that the inputs are suddenly
applied.
17The Unit Impulse Sequence
- The unit impulse has the simplest sequence
which consists of one nonzero value at n0. - The mathematical notation is the kronecker
delta, ?n. - n nlt -2 -2 -1 0 1 2 3 4
5 6 7 ngt7 - ?n 0 0 0 1 0 0 0 0 0 0 0
0 -
(2.4)
18- The Shifted Impulse response
- For example ?n-3, is nonzero when its
argument is zero. - i.e. n-3 0
-
- Why learn such a trivial signal ? What is all
this for ?
19- Example 8 The digital signal xn is
respresented as the following series of unit
impulses. Determine the original sequence of
xn. - xn 2?n 4?n-1 6?n-2 4?n-3
2?n-4 - Rule By multiplying a unit impulse we multiple
its magnitude. - Compute the signal xn from its series of unit
impulses sequence. - n nlt -2 -2 -1 0 1 2 3 4 5
6 7 ngt7 - 2?n
- 4?n-1
- 6?n-2
- 4?n-3
- 2?n-4
- xn
- Thus, we can express any digital signal as a
series of shifted unit impulses which have be
scaled by a multiplication factor.
(2.5)
20The Unit Impulse Response Sequence
- When the input to an FIR filter is a unit impulse
sequence, i.e. xn ?n, the output is by
definition a unit impulse response sequence,
i.e yn hn. - Then the general difference equation becomes.
(2.6)
21- Example 9 Take our 3-point running averager
again. - yn 1/3 xn xn1 xn2
- Its filter coefficients are bk 1/3,
1/3, 1/3 for k 0, 1 2.
1 3
1 3
1 3
22- Thus, by passing a unit impulse through any
filter we determine the pure response of the
filter for a unit input. - Example 10 An order 10 FIR filter is defined
below. Write down the impulse response of the
filter. Expand the equation and plot its impulse
response. -
23The Unit Delay
- Another trivial system that has great power is
the unit delay. - It shifts or delays a sytem by an amount
(n0). Such that - yn xn n0
- When n0 1, the system is called a unit delay.
- In a plot of yn the values of xn occur one
time interval after they do in the input.
(2.7)
24- Example 11 A system produces a delay of 3.
- a) Write down the difference equation of the
system. - b) Calculate the output yn of the system in a
difference table. - c) Plot the input and ouput of the delay 3
system. - d) Write down the impulse response equation of
the system - e) Plot the impulse response of the system
- It has filter coefficients arew bk 0, 0,
0, 1 . - NOTE Dont be fooled that this has only 1
coefficient. It has order M3 and has length L
M1 4. But coefficients 0,1,2 are weighted to
zero. - a) The difference equation is
- yn 0.xn 0.xn-1 0.xn-2 1.xn-3
- xn-3
- b) The differnce table is
- n nlt -2 -2 -1 0 1 2 3 4 5 6
7 ngt7 - xn 0 0 0 2 4 6 4 2 0 0 0
0
25c) The input and output from the delay 3
system. d) For the impulse response.
Just replace yn with hn and xn with
?n. Thus, yn xn-3 ?
hn ?n-3 1 n3 0
n?3 e) The impulse response of the delay 3
system.