Date post: | 02-Jan-2016 |
Category: |
Documents |
Upload: | alexandra-harper |
View: | 233 times |
Download: | 6 times |
Oct'04 CS3291 1
CS3291 : Digital Signal Processing '04-05
Section 3 : Discrete-time LTI systems
3.1 Introduction:
A discrete time system takes discrete time input signal { x[ n ] }, & produces an output signal { y[ n ] }.
SYSTEM input {x[n]}
output {y[n]}
Oct'04 CS3291 2
• Implemented by general purpose computer, microcomputer or
dedicated digital hardware capable of carrying out arithmetic
operations on samples of {x[n]} and {y[n]}.
• {x[n]} is sequence whose value at t=nT is x[n].
• Similarly for {y[n]}.
• T is sampling interval in seconds.
• 1/T is sampling frequency in Hz.
• {x[n-N]} is sequence whose value at t=nT is x[n-N].
{x[n-N]} is {x[n]} with every sample delayed
by N sampling intervals.
• Many types of discrete time system can be considered, e.g.
Oct'04 CS3291 3
(i) Discrete time "amplifier" with output:
y[n] = A . x[n].
• Described by "difference equation": y[n] = A x[n].
• Represented in diagram form by a "signal flow graph” .
x[n] y[n] A
Oct'04 CS3291 4
(ii) Processing system whose output at t=nT is obtained by weighting & summing present & previous input samples:
y[n] = A0 x[n] + A1 x[n-1] + A2 x[n-2] + A3 x[n-3] + A4x[n-4]
‘Non-recursive difference equatn’ with signal flow graph below. Boxes marked " z -1 " produce a delay of one sampling interval.
z-1 z-1 z-1 z-1 x[n]
A0 A1 A2 A3 A4
y[n]
Oct'04 CS3291 5
(iii) System whose output y[n] at t = nT is calculated according to the following recursive difference equation: y[n] = A 0 x[n] - B 1 y[n-1]
whose signal flow graph is given below. • Recursive means that previous values of y[n] as well as present & previous values of x[n] are used to calculate y[n].
z-1
x[n] A0
B1
y[n]
Oct'04 CS3291 6
(iv) A system whose output at t=nT is: y[n] = (x[n]) 2
as represented below.
x[n]
y[n]
Oct'04 CS3291 7
3.2. LTI Systems:
To be LTI, a discrete-time system must satisfy:
(I) Linearity ( Superposition ):
•Given any two discrete time signals {x 1 [n]} & {x 2 [n]}, if {x 1 [n]} {y 1 [n]} & {x 2 [n]} {y 2 [n]} then for any values of k 1 and k 2 , response to k 1{x 1[n]} + k 2{x 2[n]} must be k 1{y1[n]} + k 2 {y 2 [n]} .
•To multiply a sequence by k, multiply each element by k, k{x[n]} = {k x[n]}. •To add two sequences together, add corresponding samples, {x[n]} + {y[n]} = {x[n] + y[n]}.)
Oct'04 CS3291 8
(II) Time-invariance :
• Given any discrete time signal {x[n]}, if response to {x[n]} is {y[n]}, response to {x[n-N]} must be {y[n-N]} for any N.
• Delaying input by N samples only delays output by N samples.
• Examples (i), (ii) and (iii) are LTI whereas (iv) is not LTI .
Oct'04 CS3291 9
3.3. Impulse-response:
Useful to consider response of LTI systems to a discrete time unit impulse , or in short an impulse denoted by {d [n] } with:
0 n : 0
0 n : 1d[n]
... ...
1
-3 -2 -1 1 2 3 4 5
n
0
d[n-4]
... ...
1
-3 -2 -1 1 2 3 4 5
d[n]
n
0
Oct'04 CS3291 10
• {d[n-N]} is delayed impulse where the only non-zero sample occurs at n=N rather than at n=0. • When input is {d[n]}, output is impulse response {h[n]}.
• If impulse-response of an LTI system is known, its response to any other input signal may be predicted.
Oct'04 CS3291 11
3.4. Computing an impulse response:
• Consider a discrete time system with signal-flow graph below with A1, A2, A3, A4, A5 set to specific constants. • Notice the labels X1, X2, etc.
• Realised by microcomputer running a program with flow-diagram & high-level language implementation as listed next.
z-1 z-1 z-1 z-1 x[n]
A1 A2 A3 A4 A5
y[n]
X1
Y
X5X4X2 X3
Oct'04 CS3291 12
Zero X1, X2, X3, X4,X5
Set A1,A2,….
INPUT X
Y = A1*X + A2*X2 + A3*X3 +...
OUTPUT Y
X5 = X4; X4 = X3; X3 = X2; X2 =X1
clear all;
A1=1; A2=2; A3=3; A4=-4; A5=5;
x1=0; x2=0; x3=0; x4=0; x5=0;
while ~isempty(X)
X = input( 'X = '); x1 = X;
Y= A1*x1 + A2*x2 + A3*x3
+ A4*x4 + A5*x5 ;
disp([' Y = ' num2str(Y)]);
x5 = x4 ; x4 = x3;
x3 = x2 ; x2 =x1;
end;
% MATLAB program
Oct'04 CS3291 13
Here is another version using MATLAB arrays:
A = [1 2 3 -4 5 ] ;x = [0 0 0 0 0 ] ; while 1 X = input( 'X = '); x(1)=X; Y=A(1) * X; for k = 2 : 5 Y = Y + A(k)*x(k); end; disp([' Y = ' num2str(Y)]); for k=5:-1:2 x(k) = x(k-1); end;end;
Oct'04 CS3291 14
And an even more efficient version
A = [1 2 3 -4 5 ] ;x = [0 0 0 0 0 ] ; while 1
x(1) = input( 'X = ');Y = A(1)*x(1);for k = 5 : -1: 2
Y = Y + A(k)*x(k);x(k) = x(k-1);
end;disp([' Y = ' num2str(Y)]);
end;
Oct'04 CS3291 15
• These can be run in MATLAB
• The ‘while 1’ statement initiates an infinite loop.
• Program will run for ever
or until interrupted by ‘CONTROL+C’
Oct'04 CS3291 16
• Impulse-response for this example may be deduced by running
program & entering values for X on the keyboard :
0, 0, 0, 1, 0, 0, 0, 0,.... • Sequence of output samples printed out will be :
0, 0, 0, A1, A2, A3, A4, A5, 0, 0, .... • Impulse-response can also be obtained by tabulation (later). • Output must be zero until input becomes equal to 1 at n=0• Impulse response is:
{..., 0, ..., 0, A1, A2, A3, A4, A5, 0, 0, ... ,0,...}
where the sample at n=0 is underlined. • Only five non-zero output samples are observed.• This is a " finite impulse-response ” (FIR).
Oct'04 CS3291 17
Exercise 3.1: Calculate impulse-responses for difference equations:
(i) y[n] = x[n] + 2 x[n-1] + 3 x[n-2] - 4 x[n-3] + 5 x[n-4]
(ii) y[n] = 4 x[n] - 0.5 y[n-1]
Solutions: • If computer not available we may use a tabulation. • Difference eqn (i) will produce a finite impulse-response.• Difference eqn (ii) produces infinite response whose samples gradually reduce in amplitude but never quite become zero.
Oct'04 CS3291 18
(i) y[n] = x[n] + 2 x[n-1] + 3 x[n-2] - 4 x[n-3] + 5 x[n-4]
n x[n] x[n-1] x[n-2] x[n-3] x[n-4] y[n]-1 0 0 0 0 0 00 1 0 0 0 0 11 0 1 0 0 0 22 0 0 1 0 0 33 0 0 0 1 0 -44 0 0 0 0 1 55 0 0 0 0 0 0: : : : : : :
Solution is:- {.. 0, .., 0, 1, 2, 3, -4, 5, 0, .., 0, ...}
Oct'04 CS3291 19
Difference equation (ii): y[n] = 4 x[n] - 0.5 y[n-1]
n x[n] y[n-1] y[n]0 1 0 41 0 4 -22 0 -2 13 0 1 -0.54 0 -0.5 0.255 0 0.25 -0.125: : : : Solution is: {.., 0, .., 0, 4, -2, 1, -0.5, 0.25, -0.125, ...)
Oct'04 CS3291 20
3.5. Digital filters:
•A "digital filter” is a digitally implemented LTI discrete time system governed by a difference equation of finite order; e.g. :
(i) y[n] = x[n] + 2 x[n-1] + 3 x[n-2] - 4 x[n-3] + 5 x[n-4]
(ii) y[n] = 4 x[n] - 0.5 y[n-1]
• Difference equation (i) is "non-recursive" & produces a finite impulse response (FIR). • Difference equation (ii) is " recursive " . • Impulse-response of a recursive difference equation can have an infinite number of non-zero terms. In this case it is an infinite impulse-response (IIR).
Oct'04 CS3291 21
• Next slide has yet another way of programming difference equations (i.e. digital filters) in MATLAB.
• But this time, we use a MATLAB function and operate on a whole array of music at once.
• You can find the music file ‘cap4th.wav’ in
•www.cs.man.ac.uk/~barry/mydocs/CS3291/MATLAB
Oct'04 CS3291 22
MATLAB function ‘filter’ used for non-recursive diffce eqn
y = filter(A, 1, x) filters signal in array x to create array y.
For each sample x(n) of array x:
y(n) = A(1)*x(n) + A(2)*x(n-1) + ... + A(N+1)*x(n-N)
Example (i): y[n] = x[n] + 2 x[n-1] + 3 x[n-2] - 4 x[n-3] + 5 x[n-4]
[x, fs, nbits] = wavread ('cap4th.wav');sound(x,fs,nbits);pause;y = filter ( [1 2 3 -4 5], 1, x);sound(y,fs,nbits);
Oct'04 CS3291 23
Use of ‘filter’ for recursive difference equatn
y = filter(A, B, x) filters signal in array x to create array y
using a recursive difference equation.
Example (ii): y[n] = 4 x[n] - 0.5 y[n-1]
[x, fs, nbits] = wavread ('cap4th.wav');sound(x,fs,nbits);pause;y = filter ( [4], [1 0.5], x);sound(y,fs,nbits);
Oct'04 CS3291 24
3.6. Discrete time convolution:
If impulse-response of an LTI system is {h[n]} its response to any input {x[n]} is an output {y[n] } whose samples are given by the following "convolution" formulae:
m
m] x[nh[m] y[n]
k
k]h[n x[k]y[n]or
Consider the response of a system with impulse response: {h[n]} = { ..., 0,..., 0, 1, 2, 3, -4, 5, 0, .....0, .... }
to {x[n]} = { ... 0, ... , 0 , 1, 2, 3, 0, ..., 0, ....}
4]5x[n3]4x[n2]3x[n1]2x[n x[n] m] x[nh[m] y[n]4
0m
Oct'04 CS3291 25
• Result is not too surprising.
• It is the difference equation for an LTI system whose impulse
response is {.., 0, .., 0, 1, 2, 3, -4, 5, 0, .., 0, ..}.
• Program discussed earlier implements this difference equation,
•We could complete the example by running it, entering samples of
{ x[n] }, and noting the output sequence.
• Alternatively, we could use tabulation as follows:
Oct'04 CS3291 26
y[n] = x[n] + 2x[n-1] + 3x[n-2] - 4x[n-3] + 5x[n-4]
n x[n] x[n-1] x[n-2] x[n-3] x[n-4] y[n]: : : : : : :-1 0 0 0 0 0 00 1 0 0 0 0 11 2 1 0 0 0 42 3 2 1 0 0 103 0 3 2 1 0 84 0 0 3 2 1 65 0 0 0 3 2 -26 0 0 0 0 3 157 0 0 0 0 0 0: : : : : : :{y[n]} = { .... 0, ....., 0, 1, 4, 10, 8, 6, -2, 15, 0, ...., 0, ....}
Oct'04 CS3291 27
3.7. Proof of discrete time convolution formulae:
Only use defns of linearity, time-invariance & impulse-response. Since d[n-m] is non-zero only at n = m, given any sequence {x[n]},
m
m]x[m]d[nx[n]
m]}[m]{d[nx{x[n]}
m
{x[n]} is sum of infinite number of delayed impulses{d[n-m]} each multiplied by a single element, x[m]. Response to {d[n-m]} is {h[n-m]} for any value of m. response to {x[n]} is :
n allfor m][m]h[nxy[n] i.e. m]}[m]{h[nx{y[n]}
mm
Oct'04 CS3291 28
• Replacing n-m by k gives the alternative formula. • Study the graphical explanation of this proof in Section 3.17.
n
2
3
x[n]
2
h[n]
n
{h[n]} = { ..., 0, ..., 0, 1, 2, 1, 2, 0, ..., 0...}
{x[n]} = { ..., 0, ..., 0, 1, 2, 3, 0, 0, ..., 0, ...}
Oct'04 CS3291 29
3.17 Discrete time convolution graphically
n
23
x[n]
d[n]
n
2
2d[n-1]
n
3
3d[n-2]
n
2
h[n]
n
2
42h[n-1]
n
3
63h[n-2]
n
{h[n]} = { ..., 0, ..., 0, 1, 2, 1, 2, 0, ..., 0,...}
{x[n]} = { ..., 0, ..., 0, 1, 2, 3, 0, 0, ..., 0, ...}
Oct'04 CS3291 30
2
4
6
8
10
y[n]
n
Express:
{x[n]} = {d[n]} + 2 {d[n-1]} + 3 {d[n-2]}
Response is:
{y[n]} = {h[n]} + 2 {h[n-1} + 3 {h[n-2]}
Oct'04 CS3291 31
2
4
6
8
10y[n]
n
n
2
3
x[n]
{ d[n] } {h[n]}
+ 2{ d[n-1 ]} + 2 { h[n-1]}
+ 3 { d[n-2] } + 3 { h[n-2] }
{h[n]} = { ..., 0, ..., 0, 1, 2, 1, 2, 0, ..., 0,...}
{x[n]} = { ..., 0, ..., 0, 1, 2, 3, 0, 0, ..., 0, ...}
Oct'04 CS3291 32
d[n]
n
2
2d[n-1]
n
3
3d[n-2]
n
2
4
2h[n-1]
n
3
63h[n-2]
n
2
h[n]
n
Oct'04 CS3291 33
This means that {h[n]} must be either an FIR or an IIR whose samples decay towards zero as n .
3.9. Causality:
An LTI system operating in real time must be "causal " which
means that its impulse-response {h[n]} must satisfy:
h[n] = 0 for n < 0.
Non-causal system would need “crystal ball ” to predict future.
3.8. Stability:
An LTI system is stable if its impulse-response {h[n]} satisfies:
finite is ][
n
nh
Oct'04 CS3291 34
• = T is “ relative" frequency of sampled sine-wave. • Units of are 'radians per sample'. • To convert back to true frequency (radians/s ) multiply by 1/T.
• Note: 1/T = sampling frequency, f S, in samples/second (Hz).
‘radians / sample’ times ‘samples / second’ = ‘radians / second’
•Normally process analogue signals in range 0 to f S /2 ( = 1/(2T) ),
• Restricts to the range 0 to .
3.10. Relative Frequency
• Study effect of digital filters on sine-waves of different frequencies.• Discrete time sine-wave obtained by sampling A cos(t + ). • If sampling period is T seconds, resulting discrete time signal is :
)} cos( A{ )} cos( A{ n Tn
Oct'04 CS3291 35
T
3T-T
-3T 4T-4T
cos( t )
1
3-1
-3 4-4
cos( T n )
t
n
= 2 / 8
=2 / (8T)
Oct'04 CS3291 36
Table gives values of & corresponding true frequencies :-
Relative frequency True frequency(radians/sample) (radians/s) (Hz)
0 0 0/6 fS/6 fS/12/4 fS/4 fs/8/3 fS/3 fs/6/2 fS/2 fs/42/3 2fS/3 fs/3 fS fS/2
‘radians / sample’ ‘samples / second’ = ‘radians / second’
Oct'04 CS3291 37
3.11. Relative frequency response
Response to sampled sine-waves calculated by defining:
)}sin(){cos(}{ njne nj
If this is applied to a system with impulse response {h[n]}, output would be {y[n]} with :
(DTFT) ][ ][)( where
)( ][
][][][ )(
n
nj
m
mjj
njj
m
njnj
m m
mjnjmnj
enhemheH
eeHemhe
eemhemhny
Oct'04 CS3291 38
n
n
1
-1-2
3
1
3-1
-3 4-4
cos( (2/8) n )
sin( (2/8) n)
Oct'04 CS3291 39
• H( e j ) is the " relative frequency response " of LTI system.
• Complex number for any value of .
• It is DTFT of { h[n] }.
• Note similarity to the analogue Fourier transform.
(FT) )()(
(DTFT) ][)(
atj
a
n
njj
ethjH
enheH
Oct'04 CS3291 40
• If input is {e j n }, output is same sequence with each
element multiplied by H( e j ).
•When { h[n] } is real, H( e -j ) = H*( e j ).
•Exercise: Prove this.
{e j n }
{h[n]}
{ e j n H(e j n ) }
n
njj enheH ][)(
LTI
Oct'04 CS3291 41
• Remember the analogue case:-
• When h(t) is real, Ha(j ) = Ha*(j )
e j t
ha(t)
e j t Ha(j )LTI
)()(atj
a ethjH
Oct'04 CS3291 42
3.12. Gain and phase responses
• Expressing H( e j ) = G() e j ()
• G() = |H( e j )| is "gain ” • () = arg ( H( e j ) ) is "phase lead”. • Both vary with .
• If input is {A cos(n)}, • output is: { G()A cos(n + ()) } Exercise: Prove this
•When input is sampled sine-wave of rel frequency , output is sine-wave of same frequency , but with amplitude scaled by G() & phase increased by ().
Oct'04 CS3291 43
Gain & phase response graphs again
/4 /2 3/40
20log10[G()] dB-()
-()
G() in dB
Oct'04 CS3291 44
•Common to plot graphs of G() & () against . •G() often converted to dBs by calculating 20 log10( G() ). •Restrict to lie in range 0 to & adopt a linear horizontal scale.
•Example 3.2: Calculate gain & phase response of FIR digital filter in Figure 3.3 where A1 = 1, A2 = 2, A3 = 3, A4 = -4, A5 = 5 .•Solution:Impulse response is: {.., 0, .., 0, 1, 2, 3, -4, 5 ,0, .., 0,..}. By the formula established above, H( e j ) = 1 + 2 e - j + 3 e -2 j - 4 e -3 j + 5 e - 4 j
To obtain the gain and phase at any take modulus and phase. Best done by computer, either by writing & running a simple program, or by running a standard package. A simple program is given at the end of these notes.
Oct'04 CS3291 45
• Can use a spread-sheet such as excel (see lecture notes)
• Another way of calculating gain & phase responses for H( e j ) = 1 + 2 e - j + 3 e -2 j - 4 e -3 j + 5 e - 4 j
is to start MATLAB and type:
A = [ 1 2 3 -4 5 ]; freqz( A );
• See later section 3.18 for graphs produced.
Oct'04 CS3291 46
• Produces graphs of gain & phase responses of H( ej ).
• Frequency scale normalised to fS/2 & labelled 0 to 1 instead of 0 to . • See Section 3.18
• In next section we calculate coeffs of an FIR filter to achieve a particular type of gain & phase response.
• To calculate gain & phase responses for an IIR filter would be difficult by method used above because impulse-response has infinite number of non-zero terms.
•There is an easier method in a later section.
Oct'04 CS3291 47
Phase delay
• Assume input is {A cos(n)},
• Output is: { G() A cos ( n + () ) }
= { G() A cos ( [ n + () / ] ) }
= { G() A cos ( [ n - (-() / ) ] ) }
•Phase lead () delays sine-wave by -()/ sampling intervals
• This is ‘phase-delay’.
Oct'04 CS3291 48
3.13. Linear phase response
• If -()/ remains constant for all values of ,
i.e. if -() = k for constant k,
system has ‘linear phase’ response.
• Graph of -() against on linear scale would then be
straight line with slope k where k is "phase delay"
i.e. the delay measured in sampling intervals.
• This need not be an integer.
Oct'04 CS3291 49
-()/
/4 /2 3/40
-()
G() in dB
-()/
Gain, phase & ‘phase-delay’ response graphs
Not ‘linear-phase’.
Oct'04 CS3291 50
-()/
/4 /2 3/40
-()
G() in dB
-()/
Gain, phase & ‘phase-delay’ response graphs again
This is ‘linear-phase’ as -()/ is constant.
k
Oct'04 CS3291 51
• Linear phase systems of special interest since all sine-waves are
delayed by same number of sampling intervals.
• Input signal expressed as Fourier series will have all its
sinusoidal components delayed by same amount of time.
• In absence of amplitude changes, output signal will be exact
replica of input.
•LTI systems are not necessarily linear phase.
• A certain class of digital filter can be made linear phase.
Oct'04 CS3291 52
3.14. Inverse DTFT
• Frequency -response H( e j ) is DTFT of {h[n]}.
• Inverse DTFT formula allows {h[n]} to be deduced from H(e j ) :
<<-: )(2
1][ ndeeHnh njj
• Observe similarities with analogue Fourier transform:
(i) (1/2) factor, (ii) sign of jn (n replaces t). (iii) variable of integration (d)
<<-: )(
2
1)( tdejHth tj
aa
Oct'04 CS3291 53
Also note that with DTFT:
• Negative frequencies are again included.
• Range of integration is now - to rather than - to .
• Forward transform is a summation
& inverse transform is an integral.
• This is because {h[n]} is a sequence
whereas H(e j ) is function of the continuous variable .
Oct'04 CS3291 54
3.15 Problems:1. Show that y[n]=(x[n]) 2 is not LTI.2. If {h[n]}= { .. 0, .. , 0, 1, -1, 0, .. 0, .. }, calculate response to {x[n]} = { .... 0, .., 0, 1, 2, 3, 4, 0, .., 0, ... }.3.. Produce a signal flow graph for each of the following difference equations: (i) y[n] = x[n] + x[n-1] (ii) y[n] = x[n] - y[n-1]4. For each difference equation in question 3, determine the impulse response, & deduce whether the system it represents is stable and/or causal..5. Calculate, by tabulation, the output from difference equation (ii) in question 3 when the input is the impulse response of difference equation (i).6. If fS =8000 Hz, what true frequency corresponds to /5 radians/sample?7. Sketch the gain & phase responses of the system referred to in question 2. (You don't need a computer program.) Is it a linear phase system?8. Calculate the impulse response for y[n] = 4x[n] - 2y[n-1]. Is it stable?9. Show that input {cos(n)} produces an output {G()cos(n+())}.10. For y[n]=x[n]+2x[n-1]+3x[n-2]+2x[n-3]+x[n-4], sketch phase response and comment on its significance. Show that () = -2.
Oct'04 CS3291 55
3.16. Progam for gain & phase responses of FIR digital filter. (using complex arithmetic)
fs = input('enter fs:'); M = input('Enter order:'); disp('Enter coefficients:');for N = 0:M C(N+1)=input('coeff = '); end;disp(' FREQ(Hz) GAIN(dB.) PHASE LEAD(deg)');K = 0; F =0.0; % F is frequency in Hz}while F < fs/2 H=0; W =2*pi*F/fs; for N=0:M H=H+C(N+1)*exp(-j*W*N); end; MD=abs(H); PH = angle(H); GAIN(K+1)=-999; if MD>0 GAIN(K+1)=20*log10(MD);end; PHAS(K+1)=PH*180.0/pi; disp([num2str(F) ' 'num2str(GAIN(K+1)) ' 'num2str(PHAS(K+1))]); F=F+fs/200; K=K+1;end; %while loop
Oct'04 CS3291 56
3.16. Progam for gain & phase responses of FIR digital filter. (without complex arithmetic)fs = input('enter fs:'); M = input('Enter order:'); disp('Enter coefficients:');for N = 0:M H(N+1)=input('coeff = '); end;disp(' FREQ(Hz) GAIN(dB.) PHASE LEAD(deg)');K = 0; F =0.0; % F is frequency in Hz}while F < fs/2 Hre =0.0; Him =0.0; W =2*pi*F/fs; for N=0:M Hre=Hre+H(N+1)*cos(W*N); Him=Him-H(N+1)*sin(W*N); end; MD=sqrt(Hre*Hre+Him*Him); PH = atan2(Him,Hre); GAIN(K+1)=-999; if MD>0 GAIN(K+1)=20*log10(MD);end; PHAS(K+1)=PH*180.0/pi; disp([num2str(F) ' 'num2str(GAIN(K+1)) ' 'num2str(PHAS(K+1))]); F=F+fs/200; K=K+1;end; %while loop
Oct'04 CS3291 57
Sample run:- FIR FREQUENCY RESPONSE Enter sampling frequency(Hz): 1000 Enter order of FIR filter: 3 Enter coefficients:- H[0] = 1 H[1] = 2 H[2] = 1 H[3] = 2
Output obtained:-
Freq(Hz) Gain(DB) Phase(deg) 0 15.56 0.0 5 15.56 -3.0 10 15.56 -6.0 : : : 500 6.01 -180.0 }
Oct'04 CS3291 58
3.18. Frequency response of FIR digital filter by MATLAB
• Given discrete time LTI system with difference equation:y[n] = x[n] + 2 x[n-1] + 3 x[n-2] - 4 x[n-3] + 5 x[n-4] • Its impulse response is: { ... , 0, ... , 0, 1 , 2, 3, -4, 5, 0, ..., 0, ... }• Its frequency response is:H( e j ) = 1 + 2 e - j + 3 e -2 j - 4 e -3 j + 5 e - 4 j
• To calculate its gain and phase responses, type:
freqz ( [ 1 2 3 -4 5 ]) ;
• Resulting graphs have a normalised frequency scale with “1” corresponding to = radians/sample; i.e. one half of the sampling frequency.
Oct'04 CS3291 59
Oct'04 CS3291 60