FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 1
CHAPTER Zero :
Outlines
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 2
PREFACE
This bookIntegrating Matlab with traditional topics on DSPUse Matlab to explore difficult topics and solve problems to gain insightMatlab provides a convenient tool so that many scenarios can be tried with easeEnhance the learning processAssume that the student is familiar with the fundamental of MATLAB
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 3
PREFACE
Organization of the BookChapter 1, IntroductionChapter 2, Discrete-time Signals and SystemsChapter 3, The Discrete-time Fourier AnalysisChapter 4, The Z-TransformChapter 5, The Discrete Fourier TransformChapter 6, Digital Filter StructuresChapter 7, FIR Filter DesignChapter 8, IIR Filter Design...... And more topics
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 4
CHAPTER One :Introduction
Introduce the discipline of Signal ProcessingDiscuss the advantages of DSP over analog signal processingIntroduce the MATLAB
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 5
INTRODUCTION
The field of DSP has grown to be important both theoretically and technologically.
Development and use of low-cost software and hardwareNew technologies and applications take advantage of DSP algorithmsMake DSP an integral part of any E.E. curriculum
What facilities do undergraduate students need in this DSP course ?
Advances in PCInteractive software, MATLAB
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 6
Why signals should be processed?
Signals are carriers of informationUseful and unwantedExtracting, enhancing, storing and transmitting the useful information
What signals are being processed?Analog Signal Processing vs. Digital Signal Processing
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 7
Why signals should be processed?
How are signal processed?ASP (Analog Signal Processing)Processed Using electrical networks containing active and passive circuit elements.Analog Signal - Continuously in time and amplitude
Ex) Radio & television receiver
Example: Analog Signal : xa(t) Analog signal processor ya(t) :
Analog Signal
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 8
DSP (Digital Signal Processing)
PrF ADC DSP DAC PoFAnalog Analog
Equivalent analog signal processor
PrF: antialiasing filtering to prevent aliasing
PoF: smoothing filter to smooth out the staircase waveform
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 9
DSP (Digital Signal Processing)
PrF : (Prefilter or antialiasing Filter) Conditions the analog signal to prevent aliasing
ADC :(Analog-to-Digital Converter) Produces a stream of binary number from analog Signal
DSP :(Digital Signal Processor)Heart of DSP
General-purpose computer, special-purpose processor digital hardware
DAC :(Digital-to-Analog Converter) Produce a staircase waveform from a sequence of binary numbers.
PoF : (Post filter)Smooth out staircase waveform into the desired analog Signal
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 10
Comparison of DSP over ASP
AdvantagesDeveloped using software running on a general-purpose computer with high testability and portability. DSP operations are base on additions and multiplications (so extremely stable processing, and stability independent of temperature)DSP operations can easily be modified in real time, by simple programming changes, or by reloading of registerDSP has lower cost due to VLSI technology. (memory, gates, microprocessor)
DisadvantagesLow speed in very high frequency
DSP ApplicationsConsumer electronics, Communications, Wireless telephones, Medical Image
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 11
Signal Analysis: measure signal properties and find what it is in the received signal
Spectrum (frequency/phase) analysisSpeech recognitionSpeaker verificationTarget detection
Signal Filtering: improve the signal quality from corrupted signals by signal-in-signal-out filter
Removal of unwanted background noise/interferenceSeparation of frequency bandsShaping of the signal spectrum
The two categories of DSP Tasks
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 12
What is DSP Used For?
……And much more!And much more!
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 13
Speech Processing
Speech coding/compressionSpeech synthesisSpeech recognition
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 14
Some Properties of Speech
The blue--- s---p--o---------t i-s--on--the-- k--ey a---g--ai----n------
“oo” in “blue”“o” in “spot”“ee” in “key”“e” in “again”“s” in “spot”“k” in “key”
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 15
Some Properties of Speech
“ee” in “key”“o” in “spot”“oo” in “blue” “e” in “again”
Vowels
“s” in “spot” “k” in “key”
Consonants
•Quasi-periodic
•Relatively high signal power
•Non-periodic (random)
•Relatively low signal power
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 16
Speech Coding
BTS(Base Transceiver)
BSC (Base Station Controller)
MSC(Mobile Switching Center) TRAU(Transcoder/Rate
Adapter Unit)
64 kbits/s
13 kbits/s 22.8 kbits/s
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 17
Try to predict the current sample value;Transmit the prediction error.
Speech Coding – Linear Prediction
ΣA(z)
s(n)+– d(n)
se(n)Σ…
d(n)
A(z)
++
se(n)
sr(n)
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 18
Standard music CD:Sampling Rate: 44.1 kHz16-bit samples2-channel stereoData transfer rate = 2×16×44,100 = 1.4 Mbits/s1 hour of music = 1.4×3,600 = 635 MB
Digital Audio
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 19
Key standards:MPEG: Layers I, II, and III (MP3); AAC.
used in DAB, DVDDolby AC3, Dolby Digital, Dolby Surround.
Typical bit rates for 2-channel stereo:64kbits/s to 384 kbits/s.
Subband- or transform-based, making use of perceptual masking properties.
Audio Coding (Cont’d)
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 20
Still Image Coding:JPEG (Joint Photographic Experts Group):
Discrete Cosine Transform (DCT) basedJPEG2000: Wavelet Transform based
Video Coding:MPEG (Moving Pictures Experts Group):
DCT-based,Interframe and intraframe prediction,Motion estimation.
Applications: Digital TV, DVD, etc.
Image/Video
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 21
JPEG Example
Original
JPEG (100:1)JPEG (4:1)
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 22
Self-learning: Filter coefficients adapt in response to training signal.
• Filter update: Least Mean Squares (LMS) algorithm
Adaptive Filtering
W(z) Σ+–x(n)
y(n)e(n)
d(n)
)()(2)()1( nnenn xww μ+=+
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 23
Echo cancellation (telephone lines)Used in modems (making Internet access possible!!)
Adaptive equalizationActive noise controlMedical signal processing
e.g. foetal heart beat monitoringImage analysis, e.g:
Face recognition,Optical Character Recognition (OCR);
Adaptive Filtering Applications
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 24
Restoration of old image, video, and audio signals;Analysis of RADAR data;Analysis of SONAR data;Data transmission (modems, radio, echo cancellation, channel equalization, etc.);Storage and archiving;Control of electric motors.
Adaptive Filtering Applications
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 25
Selecting a DSP – several choices:Fixed-point;Floating point;Application-specific devices(e.g. FFT processors, speech recognizers,etc.).
Main DSP Manufacturers:Texas Instruments (http://www.ti.com)Motorola (http://www.motorola.com)Analog Devices (http://www.analog.com)
DSP Devices & Architectures
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 26
FEW WORDS ABOUT MATLABMATLAB is an interactive, matrix –based system for scientific and engineering numeric computation and visualization
MATLAB Tutorial : Referenced from Tolga Kurt [1]
FEW WORDS ABOUT MATLAB
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 27
Getting Started
Matlab - Matrix laboratoryA high-level technical computing language and interactive environment Useful for :
analyzing datadeveloping algorithms and applications
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 28
Defining vectors and matrices –(1/2)
Defining a matrixRows are separated by semicolons.Semicolons will prevent the results display on the command window.To display type the name of the variable.
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 29
Defining vectors and matrices –(2/2)
Definition with increments:
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 30
Basic Operations
Element by element operations:A+B Element by element additionA-B Element by element subtractionA*B Matrix multiplicationA.*B Element by element multiplicationA/B A*inv(B)A./B Element by element divisionA^B Matrix powerA.' TransposeA' Complex conjugate transposeA^-1 Matrix inverse - inv(A)
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 31
Graphs
Using built in function
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 32
M-file example
%%Generate two random shifted BPSKclearclose allclclist=[.5 .6 .7 .8 .9 1]count=0;for k=list;
count=count+1R1=sqrt(k);R2=sqrt(1-k);mx2=0;itmax=100000;av=0;
for t=1:itmaxA=R1*(randint(64,1,2)*2-1);B=R2*(randint(64,1,2)*2-1);
Tran=A+B*j;
av=av+mean(abs(Tran).^2)/itmax;
endson(count)=10*log10(mx2/av);
endplot(list,son)
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 33
M-file example
% MATLAB script that generates the probability of error versus the signal to noise ratio.initial_snr=0;final_snr=12;snr_step=0.75; tolerance=eps; % Tolerance used for the integrationplus_inf=20; % This is practically infinitysnr_in_dB=initial_snr:snr_step:final_snr;for i=1:length(snr_in_dB),
snr=10^(snr_in_dB(i)/10);Pe_2(i)=1-quad8('bdt_int2',0,plus_inf,tolerance,[],snr,2);Pe_4(i)=1-quad8('bdt_int2',0,plus_inf,tolerance,[],snr,4);Pe_8(i)=1-quad8('bdt_int2',0,plus_inf,tolerance,[],snr,8);Pe_16(i)=1-quad8('bdt_int2',0,plus_inf,tolerance,[],snr,16);Pe_32(i)=1-quad8('bdt_int2',0,plus_inf,tolerance,[],snr,32);
end;
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 34
M-file example
% Plotting commands followt=snr_in_dB;semilogy(t,Pe_2,'-',t,Pe_4,'--',t,Pe_8,'-.',t,Pe_16,':',t,Pe_32,'-')legend('M=2','M=4','M=8','M=16','M=32',0);axis([initial_snr,final_snr,1e-16,1e0])
xlabel('Input SNR per Bit','fontsize',16,'fontname','Arial')ylabel('Symbol Error Rate (SER)','fontsize',16,'fontname','Arial')set(findobj('Type','line'),'LineWidth',2)set(findobj('fontname','Helvetica'),'fontname','Times new Roman','fontsize',16)title('Symbol error probability for biorthogonal signals')hold off
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 35
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 36
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 37
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 38
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 39
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 40
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 41
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 42
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 43
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 44
DSP example
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 45
More about Matlab
MATLAB Tutorial by張智星
[email protected]://neural.cs.nthu.edu.tw/jang/
Topics01-MATLAB小傳與外觀02-初探MATLAB03-二維平面繪圖09-矩陣的處理與運算14-MATLAB 的運算元15-M檔案
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 46
Useful Referenceshttp://www.genie.uottawa.ca/~ieee/pdffiles/matlab.ppthttp://neural.cs.nthu.edu.tw/jang/http://www.math.ohiou.edu/courses/matlab/Matlab Help http://webclass.ncu.edu.tw/~junwu/index.htmlhttp://caig.cs.nctu.edu.tw/course/NM/slides/MatlabTutorial.pdfhttp://users.ece.gatech.edu/~bonnie/book/TUTORIAL/tutorial.htmlContemporary communication systems using MATLAB / J. G. Proakis, M. Salehi.MATLAB programming for engineers / Stephen J. Chapman. Simulation and Software Radio for Mobile Communications, Chapter 2, H. Harada and R. Prasad …
FJU-EE – YUJL – Introduction DSP– Chapter1 - Page 47
http://www.math.ohiou.edu/courses/matlab/Math410, 1,2,3,4,5
Due date: 本章結束後當週星期五。
§ HomeWork
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 1
Chapter 2. Discrete-Time Signals and
Systems
Important types of signals and their operationsLinear and shift-invariant systemThe convolution and difference equation representationsRepresentations and implementation of signal and systems using MATLAB
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 2
§2.1 Discrete-Time Signals
Category of signals : Analog and discrete signalsAnalog signal xa(t)
t represents any physical quantity, time in sec.Discrete-Time Signals x(n) :
n is integer valued, represents discrete instances in time.A discrete-time signal, which is a number sequence, will be denoted by one of the following notations:
where the up-arrow indicates the sample at n=0.
( ) { ( )} { , ( 1), (0), (1), }x n x n x x x= = −↑
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 3
§2.1 Discrete-Time Signals
In Matlab, a finite-duration sequence representation requires two vectors, and each for x and n.
Example:
Then in Matlab :
Question: whether or not an arbitrary infinite-duration sequence can be represented in MATLAB?
( ) {2,1, 1, 0,1,4,3,7}x n = −↑
];7,3,4,1,0,1,1,2[];4,3,2,1,0,1,2,3[
−=−−−=
xn
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 4
Types of Elementary Sequences
Unit sample sequence δ(n)
Representation in MATLABn=[n1:n2]; x = zeros(1,n2n=[n1:n2]; x = zeros(1,n2--n1+1); x(n0n1+1); x(n0--n1+1)=1;n1+1)=1;n=-2:30; x=[zeros(1,2),1,zeros(1,30)];stem(n,x);n=[n1:n2]; x = [(n-n0)==0]; stem(n,x,’ro’);
{ }1, 0( ) ,0,0,1,0,0,0, 0n
nn
δ↑
=⎧= =⎨ ≠⎩
00
0
1,( )
0,n n
n nn n
δ=⎧
− = ⎨ ≠⎩
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 5
Types of Elementary Sequences
Unit sample sequence
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 6
Unit Step Sequence u(n)
Unit step sequence
Representation in MATLABn=0:30; x=[ones(1,31)]; stem(n,x);n=[n1:n2]; x=[(n-n0)>=0];
00
0
1, 0( ) ,0,0, 1,1,1,
0, 0
1,( )
0,
nu n
n
n nu n n
n n
≥ ⎧ ⎫⎧= =⎨ ⎨ ⎬
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 7
Unit Step Sequence u(n)
Unit step sequence
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 8
Real-valued exponential sequence
Real-valued exponential sequence
Rananx n ∈∀= ;,)(For Example: 100,)9.0()( ≤≤= nnx n
n=[0:10]; x=(0.9).^n; stem(n,x,’ro’)
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 9
Real-valued exponential sequence
1. a=3/4;2. n=0:10;3. x=a.^n;4. subplot(2,1,1)5. stem(n,x);
1. a=4/3;2. n=0:10;3. x=a.^n;4. subplot(2,1,2)5. stem(n,x);
( ) , ;nx n a n a R= ∀ ∈
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 10
Complex-valued exponential sequence
Complex-valued exponential sequence
nenx nj ∀= + ,)( )( 0ωσ
σ: Attenuation: 衰减因子Ω0: frequency in radians:
For Example: n=[0:10]; x=exp((2+3j)*n);
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 11
Sinusoidal Sequence
Complex-valued exponential sequence
1. a=2;f0=4;phi=pi/6;2. w0=2*pi*f0;3. t=0:.001:1;4. x=a*sin(w0*t+phi);5. plot(t,x);6. ylable('x(t)');xlable('Time (s)');7. title('sinusoidal signal');
0( ) cos( ),x n A n nω θ= + ∀
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 12
Random Sequence
In Matlab two types of (pseudo-) random sequences are available.
The rand(1,N) generates a length N random sequence whose elements are uniformly distributed between[0,1].The randn(1,N) generates a length N Gaussian random sequence with mean 0 and variance 1.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 13
Periodic sequence
A sequence x(n) is periodic if x(n)=x(n+N)The smallest integer N is called the fundamental periodFor example
A: xtilde=[x,x,x,x,x,x,x,x,x,x,x,x,x]B: xtilde=x’*ones(1,P); xtilde=xtilde(:); xtilde=xtilde’;
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 14
OPERATIONS ON SEQUENCES
Signal additionSignal multiplicationScalingShiftingFoldingSample summationSample productsSignal energySignal power
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 15
1. Signal addition
Signal addition is a sample-by-sample addition given by{x1(n)}+{x2(n)}={x1(n)+x2(n)}It is implemented in Matlab by the arithmetic operator ”+”. However, the lengths of x1(n) and x2(n) must be the same. The following function called the sigadd function, demonstrates these operations.1. function [y,n]=sigadd(x1,n1,x2,n2)2. n=min(min(n1),min(n2)): max(max(n1),max(n2));3. y1=zeros(1,length(n)); y2=y1;4. y1(find((n>=min(n1)) & (n=min(n2)) & (n
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 16
2. Signal multiplication
Signal multiplication is a sample-by-sample multiplication given by
{x1(n)}.{x2(n)}={x1(n)x2(n)}It is implemented in Matlab by the arithmetic operator ”.*”. Once again the similar restrictions apply for the .* operator . Therefore we have developed the sigmult function, which is similar to the sigadd function.1. function [y,n]=sigmult(x1,n1,x2,n2)2. n=min(min(n1),min(n2)) : max(max(n1),max(n2));3. y1=zeros(1,length(n)); y2=y1;4. y1(find((n>=min(n1)) & (n=min(n2)) & (n
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 17
3. Scaling
In this operation each sample is multiplied by a scalar α.α{x(n)}={αx(n)}An operator “*” is used to implement the scaling operation in Matlab.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 18
4. Shifting
In this operation each sample of x(n) is shifted by an amount k to obtain x(n-k).
y(n)={x(n-k)}Or if we let m=n-k, y(m+k)={x(m)}
This is shown in the function sigshift. function [y,n] = sigshift(x,m,n0)% implements y(n) = x(n-n0)n = m+n0; y = x;
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 19
5. Folding
In this operation each sample of x(n) is flipped around n=0 to obtain a folded sequence x(-n).
y(n)={x(-n)}This is shown in the function sigfold.
function [y,n] = sigfold(x,n)% implements y(n) = x(-n)y = fliplr(x); n = -fliplr(n);%fliplr
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 20
6. Sample summation
It adds all sample values of x(n) between n1 and n2It is implemented by the sum(x(n1:n2)) function.
)(...)()( 212
1
nxnxnxnn
nn
++=∑=
=
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 21
7. Sample products
It multiplies all sample values of x(n) between n1 and n2.It is implemented by the prod(x(n1:n2)) function.
2
1 21
( ) ( ) ... ( )n
n
x n x n x n= × ×∏
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 22
8. Signal energy
The energy of a sequence x(n) is given by
The energy of a finite-duration sequence x(n) can be computed in MATLAB using
Ex=sum(x.*conj(x));% one approachEx=sum(abs(x).^2); % another approach
2*( ) ( ) ( )xn n
x n x n x nε∞ ∞
=−∞ =−∞
= =∑ ∑
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 23
9.Signal power
The average power of a periodic sequence withfundamental period N is given by
12
0
1 ( )N
xn
P x nN
−
=
= ∑
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 24
EXAMPLE 2.1
EXAMPLE 2.1 Generate and plot each of the following sequences over the indicated interval.
% a) x(n) = 2*delta(n+2) - delta(n-4), -5
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 25
EXAMPLE 2.1
% c) x(n) = cos(0.04*pi*n) + 0.2*w(n); 0
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 26
EXAMPLE 2.1
−5 0 5−2
−1
0
1
2
3Sequence in Example 2.1a
n
x(n)
0 5 10 15 20
0
2
4
6
8
10
Sequence in Example 2.1b
n
x(n)
0 10 20 30 40 50
−1
−0.5
0
0.5
1
Sequence in Example 2.1c
n
x(n)
−10 −5 0 5−1
0
1
2
3
4
5
6Sequence in Example 2.1d
n
xtild
e(n)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 27
EXAMPLE 2.2
Let x(n)={1,2,3,4,5,6,7,6,5,4,3,2,1}. Determine and plot the following sequences.
figure(1); clfn = -2:10; x = [1:7,6:-1:1];% a) x1(n) = 2*x(n-5) - 3*x(n+4)1. [x11,n11] = sigshift(x,n,5); [x12,n12] = sigshift(x,n,-4);2. [x1,n1] = sigadd(2*x11,n11,-3*x12,n12);3. subplot(2,1,1); stem(n1,x1); title('Sequence in Example 2.2a')4. xlabel('n'); ylabel('x1(n)'); axis([min(n1)-1,max(n1)+1,min(x1)-
1,max(x1)+1])5. set(gca,'XTickMode','manual','XTick',[min(n1),0,max(n1)])
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 28
EXAMPLE 2.2
% b) x2(n) = x(3-n) + x(n)*x(n-2)1. [x21,n21] = sigfold(x,n); [x21,n21] = sigshift(x21,n21,3);2. [x22,n22] = sigshift(x,n,2); [x22,n22] = sigmult(x,n,x22,n22);3. [x2,n2] = sigadd(x21,n21,x22,n22);4. subplot(2,1,2); stem(n2,x2); title('Sequence in Example 2.2b')5. xlabel('n'); ylabel('x2(n)'); axis([min(n2)-1,max(n2)+1,0,40])6. set(gca,'XTickMode','manual','XTick',[min(n2),0,max(n2)])
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 29
EXAMPLE 2.2
−6 0 15
−20
−15
−10
−5
0
5
10
15Sequence in Example 2.2a
n
x1(n
)
−7 0 120
10
20
30
40Sequence in Example 2.2b
n
x2(n
)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 30
EXAMPLE 2.3
Generate the complex-valued signalx(n) = exp((-0.1+j0.3)n), for -10≦n ≦ 10
And plot its magnitude, phase , the real part, and the imaginary part in four separate subplots.Solution : figure(1); clf
1. n = [-10:1:10]; alpha = -0.1+0.3j;2. x = exp(alpha*n);3. subplot(2,2,1); stem(n,real(x));title('real part');xlabel('n')4. subplot(2,2,2); stem(n,imag(x));title('imaginary part');xlabel('n')5. subplot(2,2,3); stem(n,abs(x));title('magnitude part');xlabel('n')6. subplot(2,2,4); stem(n,(180/pi)*angle(x));title('phase part');xlabel('n')
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 31
EXAMPLE 2.3
−10 −5 0 5 10−3
−2
−1
0
1
2real part
n−10 −5 0 5 10−2
−1.5
−1
−0.5
0
0.5
1imaginary part
n
−10 −5 0 5 100
0.5
1
1.5
2
2.5
3magnitude part
n−10 −5 0 5 10
−200
−100
0
100
200phase part
n
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 32
Some useful results
Unit sample synthesisAny arbitrary sequence x(n) can be synthesized as a weighted sum of delayed and scaled unit sample sequences, such as
Even and odd synthesisA real-valued sequence x0(n) is called even (symmetric) if
xe(n)=xe(-n)A real-valued sequence x0(n) is called odd (antisymmetric) if
x0(n)=x0(-n)
∑∞
−∞=
−=k
knkxnx )()()( δ
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 33
Some useful results
Then the arbitrary real-valued sequence x(n) can be decomposed into its even and odd components.
x(n)=xe(n)+x0(n)where the even and odd parts are given by
xe(n)=1/2[x(n)+x(-n)] and x0 (n)=1/2[x(n)-x(-n)] We will use this decomposition in studying properties of the Fourier transform. Using MATLAB operations discussed so far, we can obtain the following evenoddfunction.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 34
Evenodd functionfunction [xe, xo, m] = evenodd(x,n)
1. % Real signal decomposition into even and odd parts 2. % [xe, xo, m] = evenodd(x,n)3. if any(imag(x) ~= 0)4. error('x is not a real sequence')5. end6. m = -fliplr(n);7. m1 = min([m,n]); m2 = max([m,n]); m = m1:m2;8. nm = n(1)-m(1); n1 = 1:length(n);9. x1 = zeros(1,length(m));10. x1(n1+nm) = x; x = x1;11. xe = 0.5*(x + fliplr(x));12. xo = 0.5*(x - fliplr(x));
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 35
EXAMPLE 2.4
Let x(n)=u(n)-u(n-10). Decompose x(n) into even and odd components.Solution :
1. n = [0:10];2. x = stepseq(0,0,10)-stepseq(10,0,10);3. [xe,xo,m] = evenodd(x,n);4. subplot(1,1,1)5. subplot(2,2,1); stem(n,x); title('Rectangular pulse')6. xlabel('n'); ylabel('x(n)'); axis([-10,10,0,1.2])7. subplot(2,2,2); stem(m,xe); title('Even Part')8. xlabel('n'); ylabel('xe(n)'); axis([-10,10,0,1.2])9. subplot(2,2,4); stem(m,xo); title('Odd Part')10. xlabel('n'); ylabel('xe(n)'); axis([-10,10,-0.6,0.6])
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 36
EXAMPLE 2.4
−10 −5 0 5 100
0.2
0.4
0.6
0.8
1
1.2Rectangular pulse
n
x(n)
−10 −5 0 5 100
0.2
0.4
0.6
0.8
1
1.2Even Part
n
xe(n
)
−10 −5 0 5 10
−0.4
−0.2
0
0.2
0.4
0.6Odd Part
n
xe(n
)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 37
The geometric series
A one-side exponential sequence of the form {an, n>=0}, where a is an arbitrary constant, is called a geometric series. The series converges for |a|
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 38
Correlations of sequences
It is a measure of the degree to which two sequences are similar. Given two real-valued sequences x(n) and y(n) of finite energy,
the cross correlation of x(n) and y(n) is a sequence rxy(l) defined as
When y(n)=x(n) is called autocorrelation and is defined by
∑∞
−∞=
−=n
yx lnynxlr )()()(,
∑∞
−∞=
−=n
xx lnxnxlr )()()(,
The index l is called the shift or lag parameter.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 39
§2.2 DISCRETE SYSTEMS
Mathematically, discrete system is an operation T[.]y(n) = T [ x(n)]x(n): excitation, input signaly(n): response, output signal
Discrete systems are broadly classified into linear and nonlinear systems. We will deal mostly with linear systems.A discrete system T[.] is a linear operator L[.] if and only if L[.] satisfies the principle of superposition, namely,
)(),(,,)]([)]([)]()([
2121
22112211
nxnxaanxLanxLanxanxaL
∀+=+
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 40
Linear System
The output y(n) of a linear system to an arbitrary input x(n) is given by
The response can be interpreted as the response of a linear system at time n due to a unit sample at time k. It is called an impulse response and is denoted by h(n,k). The output then is given by the superposition summation
( ) [ ( )] ( ) ( ) ( ) [ ( )]n n
y n L x n L x k n k x k L n kδ δ+∞ +∞
=−∞ =−∞
⎡ ⎤= = − = −⎢ ⎥⎣ ⎦∑ ∑
)]([ knL −δ
(( ) ( ) ( , ) [, ( ], ))n
y n x k h n k L nn k kh δ∞
=−∞
== −∑
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 41
Linear time-invariant (LTI) sysem
Linear time-invariant (LTI) system A linear system in which an input-output pair, x(n) and y(n), is invariant to a shift k in time.y(n) = L[x(n)] y(n-k) = L[x(n-k)]For an LTI system the L[.] and the shifting operators are reversible as shown below.
h(n) ≣h(n,0)=L[δ(n)] h(n-k) = L[δ(n-k)]
L[.]x(n) y(n) Shift by k y(n-k)
Shift by k x(n-k) L[.] y(n-k)x(n)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 42
Linear time-invariant (LTI) sysem
The output of an LTI system to input x(n) is given by
The impulse response of an LTI system is given by h(n). The mathematical operation shown above is called a linear convolution sum and is denoted by y(n)=x(n)*h(n). Hence an LTI system is completely characterized in the
time domain by the impulse response h(n) as shown below.
( ) ( ) ( , ) ( ) ( ) ( ) ( )n n
y n x k h n k x k h nn hk x n∞ ∞
=−∞ =−∞
≡= ∗= −∑ ∑
x(n) h(n) y(n)=x(n)*h(n)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 43
Stability
A system is said to be bounded-input bounded-output (BIBO) stable if every bounded input produces a bounded output.An LTI system is BIBO stable if and only if its impulse response is absolutely summable
BIBO Stability ( ) ( ) , ,
( )
x n y n x y
h n∞
−∞
←→ < ∞⇒ < ∞ ∀
←→ < ∞∑
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 44
Causality
This important concept is necessary to make sure that systems can be built.
A system is said to be causal if the output at index n0 depends only on the input up to and including the index n0The output does not depend on the future values of the input.An LTI system is causal if and only if the impulse responsesatisfies h(nh(n)=0 for n
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 45
§2.3 CONVOLUTION
Convolution for an LTI system can be evaluated in many different ways
If the sequences are mathematical functions, then we can analytically evaluate x(n)*h(n) for all n to obtain a functional formof y(n)
Graphical interpretation, folded-and-shifted versionMatlab implementation1. function [y,ny]=conv_m(x,nx,h,nh)2. nyb = nx(1)+nh(1); nye = nx(length(x))+nh(length(h));3. ny = [nyb:nye];4. n = conv(x,h)
( ) ( ) * ( ) ( ) ( )k
y n x n h n x k h n k∞
=−∞
= −∑
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 46
EXAMPLE 2.5
Let the rectangular pulse x(n)=u(n)-u(n-10) of example 2.4 be an input to an LTI system with impulse response
Determine the output y(n)Solution : The input x(n) and impulse response h(n) are shown in figure 2.5. From (2.11)
It is almost a geometric series sum except that the term u(n-k) takes different values depending on n and k. There are three differentconditions under which u(n-k) can be evaluated.
9 9( )0 0
( ) ( ) ( ) (2.15)
(1)(0.9) ( ) (0.9) (0.9) ( )k
n k n kk k
y n x k h n k
u n k u n k
∞
=−∞
− −= =
= −
= − = −
∑∑ ∑
)()9.0()( nunh n=
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 47
EXAMPLE 2.5
Case 1 n
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 48
EXAMPLE 2.5
−5 0 5 10 15 20 25 30 35 40 45 500
1
2Input Sequence
n
x(n
)
−5 0 5 10 15 20 25 30 35 40 45 500
1
2Impulse Response
n
h(n
)
−5 0 5 10 15 20 25 30 35 40 45 500
5
Output Sequence
n
y(n
)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 49
EXAMPLE 2.6
The above example can also be done by using graphical convolution. In this method h(n-k) is interpreted as a folded-and-shift version of h(k). The output y(n) is obtained as a sample sum under the overlap of x(k) and h(n-k). Given a sequence x(n), what are the following sequences like?
x(n-3)x(n+2)x(-n)x(-n-3)x(-n+2)
shift
folded
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 50
EXAMPLE 2.6
Given the two sequences x(n)=[3,11,7,0,-1,4,2 ], -3≦n≦3 andh(n)=[2,3,0,-5,2,1], -1≦n≦4, determine the convolution y(n)=x(n)*h(n).Solution : we plot x(k) and h(k), the original sequences first. Thensequences h(-k), h(-1-k), … etc are plotted.
Note that the beginning point (first nonzero sample) of y(n) is given by n=-3+(-1)=-4, while the end point (the last nonzero sample) is given by n=3+4=7. the complete output is given
{ }2,8,3,22,18,41,5,51,6,47,31,6)( −−−−=ny
( ) ( ) ( )
( 1) ( ) ( 1 ) 3 ( 5) 11 0 7 3 0 2 6
(2) ( ) (2 ) 41
k
k
k
y n x k h n k
y x k h k
y x k h k
∞
=−∞
∞
=−∞
∞
=−∞
= −
− = − − = × − + × + × + × =
= − =
∑∑∑
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 51
EXAMPLE 2.6
−5 0 5
−5
0
5
10
x(k) and h(k)
k
solid: x dashed: h
−5 0 5
−5
0
5
10
x(k) and h(−k)
k
n=0
solid: x dashed: h
−5 0 5
−5
0
5
10
x(k) and h(−1−k)
k
n=−1
solid: x dashed: h
−5 0 5
−5
0
5
10
x(k) and h(2−k)
k
n=2
solid: x dashed: h
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 52
EXAMPLE 2.6
Given the two sequences x(n)=[3,11,7,0,-1,4,2 ], -3≦n≦3 andh(n)=[2,3,0,-5,2,1], -1≦n≦4, determine the convolution y(n)=x(n)*h(n).
Solution :
{ }2,8,3,22,18,41,5,51,6,47,31,6)( −−−−=ny
3
3( ) ( ) ( )
ky n x k h n k
=−= −∑
( ) ( ) ( 3) 3 ( 2) 11 ( 1) 7 (0) 0 (1) 1 (2) 4 (3) 2( 1) 2 6 22 14 0 2 8 4(0) 3 9 33 21 0 3 12 6(1) 0 0 0 0 0 0 0 0(2) 5 15 55 35 0 5 20 10(3) 2 6 22 14 0 2 8 4(4) 1 2 11 7 0 1 4 2
h n x n x x x x x x xhhhhhh
− = − = − = = = − = =− = −= −== − − − − − −= −= −
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 53
MATLAB IMPLEMENTATION
Matlab provides a built-in function called conv.m that computes the convolution between two finite duration sequence. The conv function assumes that the two sequences begin at n=0 and is invoked by
y=conv(x,h);For example, to do the convolution in Ex. 2.5, we could use
x=[3,11,7,0,-1,4,2];h=[2,3,0,-5,2,1];y=conv(x,h)
We obtain the correct convolution results but lose the time index.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 54
MATLAB IMPLEMENTATION
Let {x(n); nxb≦n≦ nxe} and {h(n); nhb≦n≦ nhe} be two finite-duration sequences. Referring to Example 2.6, we observe that the beginning and end points of y(n) are
nyb=nxb+nhb and nye=nxe+nheA simple extension of the conv function, called conv_m, which performs the convolution of arbitrary support sequences can now be designed.
1. function [y,ny] = conv_m(x,nx,h,nh)2. nyb = nx(1)+nh(1); nye = nx(length(x)) + nh(length(h));3. ny = [nyb:nye];4. y = conv(x,h);
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 55
EXAMPLE 2.7
Perform the convolution in Example 2.6 using the conv_mfunction.
x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3: 3];h = [2, 3, 0, -5, 2, 1]; nh = [-1: 4];[y,ny] = conv_m(x,nx,h,nh)Hence y(n)={6,31,47,6,-51,-5,41,18,-22,-3,8,2}
An alternate method in Matlab can be used to perform the convolution. This method uses a matrix-vector multiplication approach, which is explored in Problem 2.17.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 56
SEQUENCE CORRELATIONS REVISITED
The correlation can be computed using the conv function if sequences are of finite duration.
Example 2.8: we will demonstrate one application of the crosscorrelation sequence. Let x(n)=[3,11,7,0,-1,4,2] be a prototype sequence, and let y(n) be its noise-corrupted-and-shifted versionwhere ω(n) is Gaussian sequence with mean 0 and
variance 1. Compute the crosscorrelation between y(n) and x(n).
( ) ( ) ( ) ( ) ( ( )) ( )* ( )
( ) ( ) ( ) ( ) ( ( )) ( )* ( )
yxk k
xxk k
r n y k x k n y k x n k y n x n
r n x k x k n x k x n k x n x n
+∞ +∞
=−∞ =−∞
+∞ +∞
=−∞ =−∞
= − = − − = −
= − = − − = −
∑ ∑
∑ ∑
)()2()( nnxny ω+−=
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 57
Example 2.8
Solution Form the construction of y(n) it follows that y(n) is “similar” to x(n-2) and hence their crosscorrelation would show the strongest similarity at l=2. To test this out using Matlab, let us compute the crosscorrelation using two different noise sequences.
x = [3, 11, 7, 0, -1, 4, 2]; nx=[-3:3]; % given signal x(n)[y,ny] = sigshift(x,nx,2); % obtain x(n-2)w = randn(1,length(y)); nw = ny; % generate w(n)[y,ny] = sigadd(y,ny,w,nw); % obtain y(n) = x(n-2) + w(n)[x,nx] = sigfold(x,nx); % obtain x(-n)[rxy,nrxy] = conv_m(y,ny,x,nx); % cross-corrlationsubplot(1,1,1);subplot(2,1,1);stem(nrxy,rxy)axis([-4,8,-50,250]);xlabel('lag variable l')ylabel('rxy');title('Crosscorrelation: noise sequence 1')gtext('Maximum')
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 58
Example 2.8
−4 −2 0 2 4 6 8−50
0
50
100
150
200
250
lag variable l
rxy
Crosscorrelation: noise sequence 1
Maximum
−4 −2 0 2 4 6 8−50
0
50
100
150
200
250Maximum
lag variable l
rxy
Crosscorrelation: noise sequence 2
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 59
Example 2.8
From Figure 2.8 we observe that the crosscorrelationindeed peaks at l=2, which implies that y(n) is similar to x(n) shifted by 2. This approach can be used in applications like radar signal processing in identifying and localizing targets.It should be noted that the signal-processing toolbox in Matlab also provides a function called xcorr for sequence correlation computations. In its simplest form, we use
>>xcorr(x,y) to compute the crosscorrelation between vectors x and y, while>>xcorr(x) to compute the autocorrelation of vector x.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 60
§2.4 DIFFERENCE EQUATIONS
An LTI discrete system can also be described by a linear constant coefficient difference equation (LCCDE) of the form
if aN≠0, then the different equation is of order N. This equation describes a recursive approach for computing the current output, given the input values and previously computed output values. In practice this equation is computed forward in time, from n=-∞to ∞. Therefore another form of this equation is
nmnxbknyaN
k
M
mmk ∀−=−∑ ∑
= =
),()(0 0
∑∑==
−−−=N
kk
M
mm knyamnxbny
10)()()(
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 61
DIFFERENCE EQUATIONS
A solution to this equation can be obtained in the form
Where yH(n) is homogeneous part of the solution, is given by
zk, k=1,….N are N roots (also called natural frequencies) of the characteristic equation
If the root zk satisfy the condition |zk|
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 62
Matlab IMPLEMENTATION
A routine called filter is available to solve difference equations numerically, given the input and the difference equation coefficients.
y=filter(b,a,x)where
b=[b0,b1,…,bM] and a=[a0,a1,…,aN] are the coefficient arrays from the equation given in (2.19), and x is the input sequence array. The output y has the same length as input x. One must ensure that the coefficient a0 not be zero.
To compute impulse response, MATLAB provides the function impz(b,a,n), where n is a vector for time range.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 63
EXAMPLE 2.9
Given the following difference equation y(n)-y(n-1)+0.9y(n-2)=x(n);
a. Calculate and plot the impulse response h(n) at n=-20, …, 100.b. Calculate and plot the unit step response s(n) at n=-20,…, 100.c. Is the system specified by h(n) stable?
Solutiona=[1,-1,0.9];b=1; n=[-20:120];x=impseq(0,-20,120);h=filter(b,a,x);subplot(2,1,1);stem(n,h)axis([-20,120,-1.1,1.1])title('Impulse Response');xlabel('n');ylabel('h(n)')
h=impz(b,a,n)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 64
EXAMPLE 2.9
% Part b)x=stepseq(0,-20,120); s=filter(b,a,x);subplot(2,1,2);stem(n,s);axis([-20,120,-.5,2.5])title('Step Response');xlabel('n');ylabel('s(n)')The plot of the unit step response is shown in Figure 2.9
% Part c) Observe that h(n) is practically zero for n>120. Hence the system stability can be determined by sum(abs(h)).An alternate approach is using MATLAB’s root function.
z=roots(a); magz=abs(z); subplot
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 65
EXAMPLE 2.9
−20 0 20 40 60 80 100 120
−1
−0.5
0
0.5
1
Impulse Response
n
h(n)
−20 0 20 40 60 80 100 120−0.5
0
0.5
1
1.5
2
2.5Step Response
n
s(n)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 66
EXAMPLE 2.10
Let us consider the convolution given in Example 2.5. The input sequence is of finite duration x(n)=u(n)-u(n-10) while the impulse response is of infinite duration h(n)=(0.9)nu(n). Determine y(n)=x(n)*h(n)Solution:
If one of the sequences is of infinite length, it is more suitable to use filter instead of conv function for numerical evaluation of the convolution. Given the impulse response h(n), one can compute a difference equation and then y(n) can be obtained from the filter function.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 67
EXAMPLE 2.10
From the h(n) expression,
h(n) is the output of an LTI system when the input is δ(n). Hence substituting x(n) for δ(n) and y(n) for h(n), the difference equation is y(n)-0.9y(n-1)=x(n).Now the filter(.) function can be used to compute the convolution indirectly.
[ ]
1
( ) (0.9) ( )(0.9) ( 1) (0.9)(0.9) ( 1) (0.9) ( 1)
( ) (0.9) ( 1) (0.9) ( ) (0.9) ( 1)(0.9) ( ) ( 1) (0.9) ( ) ( )
n
n n
n n
n n
h n u nh n u n u n
h n h n u n u nu n u n n nδ δ
−
=
− = − = −
− − = − −
= − − = =
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 68
EXAMPLE 2.10
Program :b = [1]; a = [1,-0.9];n = -5:50; x = stepseq(0,-5,50) - stepseq(10,-5,50);y = filter(b,a,x);subplot(1,1,1);subplot(2,1,2); stem(n,y); title('Output sequence')xlabel('n'); ylabel('y(n)'); axis([-5,50,-0.5,8])
−5 0 5 10 15 20 25 30 35 40 45 50
0
1
2
3
4
5
6
7
8Output sequence
n
y(n)
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 69
Zero-Input and Zero-State Responses
In DSP the difference equation is generally solved forward in time from n=0. Therefore initial conditions on x(n) and y(n) are necessary to determine the output for n>=0.
Subject to the initial conditions:
The solution can be expressed in alternative form
0,)()()(0 1
≥−−−= ∑ ∑= =
nknyamnxbnyM
m
N
kkm
}1);({}1);({ −≤≤−−≤≤− nMnxandnNny
)()()( nynyny ZSZI +=
If
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 70
Zero-Input and Zero-State Responses
yZI(n): zero-input solutionA solution due to the initial conditions alone
yZS(n): zero-state solutionA solution due to input x(n) alone
Chapter 4 will discuss this topic.
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 71
Digital Filters
Discrete-time LTI systems are also called digital filter.Classification
FIR filter & IIR filterFIR filter
Finite-duration impulse response filterCausal FIR filter :
h(0)=b0,…,h(M)=bMNonrecursive or moving average (MA) filterDifference equation coefficients, {bm} and {a0=1}Implementation in Matlab: conv(x,h); filter(b,1,x) (difference?)
∑=
−=M
mm mnxbny
0)()(
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 72
Infinite Impulse Response (IIR) Filters
Infinite-duration impulse response filterDifference equation
Recursive filter, in which the output y(n) is recursively computed from its previously computed valuesAutoregressive (AR) filter
∑=
=−N
kk nxknya
0)()(
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 73
ARMA filter
Generalized IIR filter
It has two parts: MA part and AR partAutoregressive moving average filter, ARMASolution
filter(b,a,x); % given {bm}, {ak}
0 1
( ) ( ) ( ), 0M N
m km k
y n b x n m a y n k n= =
= − − − ≥∑ ∑
FJU-EE – YUJL – Introduction DSP– Chapter2 - Page 74
Homework
Textbook: pp7 to pp39Exercises:
P2.5, P2.10, P2.15, P2.16, P2.17, P2.19
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 1
Chapter 3. The Discrete-Time Fourier
Analysis
Discuss discrete-time signal and system representation in the frequency domain.Study the sampling and reconstruction of analog signals.
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 2
§3.0 Introduction
A linear and time-invariant system can be represented using its response to the unit sample sequence.
h(n) is called as the unit impulse responsey(n)=x(n)*h(n): system response
The convolution representation is based on the fact that any signal can be represented by a linear combination of scaled and delayed unit samples.We can also represent any arbitrary discrete signal as a linear combination of basis signals introduced in Chapter 2.
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 3
Each basis signal set provides a new signal representation.Each representation has some advantages and disadvantages depending upon the type of system under consideration.When the system is linear and time-invariant, only one representation stands out as the most useful. It is based on the complex exponential signal set {ejw} and is called the discrete-time Fourier Transform.
§3.0 Introduction
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 4
If x(n) is absolutely summable, i.e., , the DTFT is defined by
F[.] transforms a discrete signal x(n) into a complex-valued continuous function X of real variable w, called a digital frequency, which is measured in radians.
Time domain Frequency domainDiscrete ContinuousReal valued Complex-valuedSummation IntegralThe range of w: -∞~∞. The integral range of w: -π~ π
1
: ( ) [ ( )] ( )
1: ( ) [ ( )] ( )2
jw jwn
n
jw jw jwn
DTFT X e F x n x n e
IDTFT x n F X e X e e dwπ
ππ
+∞−
=−∞
+−
−
= =
= =
∑
∫
∑+∞∞− ∞
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 5
Determine the discrete-time Fourier transform of
Result visualization with MatlabComplex function: magnitude and angle; real/imaginary part with respect to wThe range of w:showing interval: [0,pi]
)()5.0()( nunx n=
~−∞ +∞
Example 3.1
( )0.5
jwjw
jw
eDTFT X ee
⇒ = =−
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 6
Example 3.1
0 0.2 0.4 0.6 0.8 1
0.8
1
1.2
1.4
1.6
1.8
2
frequency in pi units
Magnitude Part
Mag
nitu
de
0 0.2 0.4 0.6 0.8 1−0.7
−0.6
−0.5
−0.4
−0.3
−0.2
−0.1
0
frequency in pi units
Angle Part
Rad
ians
0 0.2 0.4 0.6 0.8 1
0.8
1
1.2
1.4
1.6
1.8
2
frequency in pi units
Real Part
Rea
l
0 0.2 0.4 0.6 0.8 1−0.7
−0.6
−0.5
−0.4
−0.3
−0.2
−0.1
0
frequency in pi units
Imaginary Part
Imag
inar
y
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 7
Periodicity:The DTFT is periodic in w with period 2πImplication: we need only one period for analysis and not the whole domain
Symmetry:For real-valued x(n), X is conjugate symmetric.Implication: to plot X, we now need to consider only a half of X: [0, π]
)()( ]2[ π+= wjjw eXeX
)()( * jwjw eXeX =−
Two important properties
Re[ ( )] Re[ ( )]Im[ ( )] Im[ ( )]| ( ) | | ( ) |
( )] ( )
jw jw
jw jw
jw jw
jw jw
X e X e even symmetryX e X e odd symmetry
X e X e even symmetryX e X e odd symmetry
−
−
−
−
=
= −
=
∠ = −∠
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 8
Matlab Implementation
If x(n) is of infinite duration, then Matlab can not be used directly to compute X from x(n).We can use DTFT to evaluate the expression X over [0, π] frequencies and then plot its magnitude and angle (or real and imaginary parts) as in Example 3.1.For a finite duration, the DTFT can be implemented as a matrix-vector multiplication operation if X is evaluated at equispaced frequency between [0, π].
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 9
Matlab Implementation
If x(n) has N samples over n1≦n≦nN and we want to evaluate X at wk=π/(Mk), k=0, 1, … M.
Stack X(ejwk) into vector form
1
( / )
1
( / )( / )
1
( ) ( ) ( ,:)
( ,:) [ ][ ( ) ( )]
pk
N
N j M knjwpp
j M knj M kn
TN
X e x n e k
k e ex n x n
π
ππ
−
=
−−
= =
=
=
∑ W xWx
0
( / )
[ ( ) ( )]
{ , 1 , 0,1, , }
exp , , column vector
M
p
jw jw T
j M kn
T T
X e X e
e p N k M
jM
π
π
−
= =
= ≤ ≤ =
⎡ ⎤⎛ ⎞= − ∈⎜ ⎟⎢ ⎥⎝ ⎠⎣ ⎦
X Wx
W
x kn k n
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 10
Example 3.4
If x(n) is of infinite duration, x(n)={1,2,3,4,5}, -1≦n≦3, determine DTFT.Solution: the vectors are in row vector form1. n=-1:3; x=1:5;2. K=0:500; w=(pi/500)*k;3. X=x*(exp(-j*pi/500).^(n’*k);4. magX=abs(X); angX=angle(X);5. realX = real(X); imagX = imag(X);6. subplot(2,2,1); plot(k/500,magX); grid;7. xlabel(‘frequency in pi unit’); title(‘Magnitude Part’);
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 11
Example 3.4
0 0.2 0.4 0.6 0.8 12
4
6
8
10
12
14
16
frequency in pi units
Magnitude Part
Mag
nitu
de
0 0.2 0.4 0.6 0.8 1−4
−2
0
2
4
frequency in pi units
Angle Part
Rad
ians
0 0.2 0.4 0.6 0.8 1−5
0
5
10
15
frequency in pi units
Real Part
Rea
l
0 0.2 0.4 0.6 0.8 1−10
−8
−6
−4
−2
0
2
4
frequency in pi units
Imaginary Part
Imag
inar
y
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 12
Example 3.5
Let x(n)= [0.9exp(jπ/3)n], 0≦n≦10. Determine X(ejwk) and study its periodicity.The DTFT of complex-valued signal is periodic in w but it is not conjugate-symmetric.
−2 −1.5 −1 −0.5 0 0.5 1 1.5 20
2
4
6
8
frequency in units of pi
|X|
Magnitude Part
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2−1
−0.5
0
0.5
1
frequency in units of pi
radian
s/pi
Angle Part
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 13
Example 3.6
Let x(n)= 2n, -10≦n≦10. Determine X(ejwk) and study its periodicity.
The DTFT of real-valued signal is periodic and conjugate-symmetric. Therefore for real sequence we will plot their Fourier transformmagnitude and angle responses from 0 to pi.
−2 −1.5 −1 −0.5 0 0.5 1 1.5 20
5
10
15
frequency in units of pi
|X|
Magnitude Part
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2−1
−0.5
0
0.5
1
frequency in units of pi
radian
s/pi
Angle Part
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 14
§3.2 The properties of the DTFT
1. Linearity:The DTFT is a linear transformation.
2. Time shifting:A shift in the time domain corresponds to the phase shifting.
3. Frequency shifting:Multiplication by a complex exponential corresponds to a shift in the frequency domain.
1 2 1 2[ ( ) ( )] [ ( )] [ ( )]F x n x n F x n F x nα β α β+ = +
[ ( )] ( )jw jwkF x n k X e e−− =
0 0( )[ ( ) ] ( )jw n j w wF x n e X e −=
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 15
The properties of the DTFT
4. Conjugation:Conjugation in the time domain corresponds to the folding and conjugation in the frequency domain.
5. Folding:Folding in the time domain corresponds to the folding in the frequency domain
6. Symmetries in real sequence:Implication: If the sequence x(n) is real and even, then X is also real and even.
* *[ ( )] ( )jwF x n X e−=
[ ( )] ( )jwF x n X e−− =
( ) ( ) ( )
[ ( )] Re[ ( )]
[ ( )] Im[ ( )]
e ojw
ejw
o
x n x n x n
F x n X e
F x n j X e
= +
=
=
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 16
The properties of the DTFT
7. Convolution:
8. MultiplicationPeriodic convolution (discussed in Chapter 5)
9. Energy
1 2 1 2 1 2[ ( ) * ( )] [ ( )] [ ( )] ( ) ( )jw jwF x n x n F x n F x n X e X e= =
1 2 1 2
( )1 2
[ ( ) ( )] [ ( )] [ ( )]
(1/ 2 ) ( ) ( )j j wF x n x n F x n F x n
X e X e dθ θπ θ−⋅ = ⊗
= ∫
2 2
2
1| ( ) | | ( ) | : Parseval's Theorem2
| ( ) |( ) : energy density spectrum
jwx
jw
x
x n X e dw
X ew
π
πε
π
π
+∞ +
−−∞
= =
Φ =
∑ ∫
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 17
Example 3.9
Let x(n)= cos(nπ/2), 0≦n≦100 and y(n)=ejnπ/4 x(n). Verify the frequency shift property by using Matlab.
−1 −0.5 0 0.5 10
10
20
30
40
50
60
frequency in pi units
|X|
Magnitude of X
−1 −0.5 0 0.5 1−1
−0.5
0
0.5
1
frequency in pi units
radi
ands
/pi
Angle of X
−1 −0.5 0 0.5 10
10
20
30
40
50
60
frequency in pi units
|Y|
Magnitude of Y
−1 −0.5 0 0.5 1−1
−0.5
0
0.5
1
frequency in pi units
radi
ans/
pi
Angle of Y
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 18
Example 3.12
Let x(n)= sin(nπ/2), -5≦n≦10. Verify the symmetry property by using Matlab.
−1 −0.5 0 0.5 1−2
−1
0
1
2
frequency in pi units
Re(X
)
Real part of X
−1 −0.5 0 0.5 1−10
−5
0
5
10
frequency in pi units
Im(X
)
Imaginary part of X
−1 −0.5 0 0.5 1−2
−1
0
1
2
frequency in pi units
XE
Transform of even part
−1 −0.5 0 0.5 1−10
−5
0
5
10
frequency in pi units
XO
Transform of odd part
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 19
§3.3 The frequency domain representation of LTI system
The Fourier transform representation is the most useful signal representation for LTI systems.It is due to the following result:
Response to a complex exponential ejw0nResponse to sinusoidal sequencesResponse to arbitrary sequences
Those responses are called the stead-state responses of systems.
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 20
Response to a complex exponential
Response to a complex exponential
Frequency response: the DTFT of an impulse response is called the frequency response (or transfer function) of an LTI system and is denoted by H().
The output sequence is the input exponential sequence modified by the response of the system at frequency w0
)(nhnjwe 0njw
wwnjw enhFenh 0
0
0 ]|)]([[*)( ==
( ) [ ( )] ( )jw jnwn
H e F h n h n e∞=−∞
= = ∑
)( jweHnjwe 0 njwjw eeH 00 )( ×
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 21
Response to a complex exponential
Response to multiple complex exponential sequences
In general, the frequency response H is a complex function of w.
The magnitude |H| is called the magnitude (gain) response function, and the the angle is called the phase response function.
)(),( nheH jw∑k
njwk
keA ∑k
njwjwk
kk eeHA )(
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 22
Response to sinusoidal sequences
Response to x(n)= Acos(w0n+θ0),
)(nh0 0cos( )w n θ+( ) ?y n =
0 0
0 0
0 0
0 0
( ) cos( )
( ) | ( ) | cos( ( ))
( ) cos( )
( ) | ( ) | cos( ( ))
jw jw
k k kk
jw jwk k k
k
x n A w n
y n A H e w n H e
x n A w n
y n A H e w n H e
θ
θ
θ
θ
= +
= + +∠
= +
= + +∠
∑
∑
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 23
Response to arbitrary sequences
Let X=F[x(n)] and Y=F[y(n)]. Then using convolution property, we have
)(nh)(nx )(*)()( nxnhny =
)(),( nheH jw)( jweX )()()( jwjwjw eXeHeY =
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 24
Example 3.13
Plot the magnitude and the phase responses of a system characterized by h(n)=(0.9)nu(n).
1( )1 0.9
jwjwX e e−
=−
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
2
4
6
8
10
frequency in pi units
|H|
Magnitude Response
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−0.4
−0.3
−0.2
−0.1
0
frequency in pi units
Phas
e in p
i Rad
ians
Phase Response
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 25
Frequency response function from difference equations
To evaluate its frequency response , we would need the impulse response h(n).How do we do when an LTI system is represented by the difference equation?
We know that when , then y(n) must be
∑ ∑= = −=−+Nl
Mm ml mnxblnyany 1 0 )()()(
jwnenx =)(jwnjw eeH )(
∑∑
=−
=−
+= N
ljwl
l
Mm
jwmmjw
eaeb
eH0
0
1)(Therefore,
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 26
Example 3.15
An LTI system is specified by y(n)=0.8y(n-1)+x(n). (a.) Determine X(ejw) and (b.) Plot the steady-state response to x(n)=cos(0.05nπ)u(n)
0 10 20 30 40 50 60 70 80 90 100−1
−0.5
0
0.5
1
n
x(n)
Input sequence
0 10 20 30 40 50 60 70 80 90 100−5
0
5
n
y(n)
Output sequence
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 27
Example 3.16
We can generalize the frequency response by using a simple matrix-vector multiplication.
If X is evaluated at equispaced frequency between [0, π] with K points
0 1 0 1
( ) exp( ). / exp( )[ , , ]; [ , , ][0,1,2, , ]; [0,1,2, , ][0,1,2, , ]; * /
jw T T
M N
H e j jb b b a a a
M NK pi K
= − −= == == =
b m w a n wb am nk w k
0
0
( )1
M jwmmjw m
N jwnln
b eH e
a e
−=
−=
=+
∑∑
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 28
Example 3.16
A 3rd-order lowpass filter with difference equation
1. b = [0.0181, 0.0543, 0.0543, 0.0181];2. a = [1.0000, -1.7600, 1.1829, -0.2781];3. m = 0:length(b)-1; l = 0:length(a)-1;4. K = 500; k = 1:1:K;5. w = pi*k/K; % [0, pi] axis divided into 501 points.6. num = b * exp(-j*m'*w); % Numerator calculations7. den = a * exp(-j*l'*w); % Denominator calculations8. H = num ./ den;9. magH = abs(H); angH = angle(H);
( ) 0.0181 ( ) 0.0543 ( 1) 0.0543 ( 2) 0.0181 ( 3)1.76 ( 1) 1.1829 ( 2) 0.2781 ( 3)
y n x n x n x n x ny n y n y n
= + − + − + −+ − − − + −
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 29
Example 3.16
A 3rd-order lowpass filter with difference equation
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.2
0.4
0.6
0.8
1
frequency in pi units
|H|
Magnitude Response
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−1
−0.5
0
0.5
1
frequency in pi units
Phas
e in
pi R
adia
ns
Phase Response
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 30
§3.4 Sampling and reconstruction of analog signals
Analogy signals can be converted into discrete signals using sampling and quantization operations: analogy-to-digital conversion, or ADCDigital signals can be converted into analog signals using a reconstruction operation: digital-to-analogy conversion, or DACUsing Fourier analysis, we can describe the sampling operation from the frequency-domain view-point, analyze its effects and then address the reconstruction operation.We will also assume that the number of quantization levels is sufficiently large that the effect of quantization on discrete signals is negligible.
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 31
Sampling
Let xa(t) be analog signal. We have FT/IFT pair
Assume xa(t) is Absolutely integrableΩ(or F) is an analogy frequency in radians/secω (or f) is a digital frequency radians/secAnalogy and digital frequencies are related through sampling rate Fs=1/Ts, ω=Ω/Fs, f=F/Fs.
Sampling: Sample xa(t) at sampling interval Ts sec apart to obtain the discrete-time signal x(n)
1( ) ( ) ( ) ( )2
IFTj t j ta a a aFT
X j x t e dt x t X j e dπ
+∞ +∞− Ω Ω
−∞ −∞⎯⎯→Ω = = Ω Ω←⎯⎯∫ ∫
( ) ( )1 2( ) ( )
a s
s ans s s
x n x t nT
X X nT T T
ω πω
= =
⇒ = −∑
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 32
Sampling
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 33
Sampling
Fig3.10
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 34
Sampling
X is a countable sum of amplitude-scaled, frequency-scaled, and translated version of xa(t) The above relation is known as the aliasing formulaSuppose signal band is limited to ±Ώ0,If Ts is small, Ώ0Tsπ Ώ0>π/Ts, orF0= Ώ0/2π > 1/2Ts = Fs/2 Fs
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 35
Sampling
Sampling:
1( ) ( ) ( ) ( )
1( ) ( ) ( )
1 2( )
s a a sns
s s a s sns s
ans s s
X X P X nT
X X X F nF T
X nT T T
ω ω
ω π
Ω = Ω ∗ Ω = Ω − Ω
Ω⇒ ≡ = − Ω
= −
∑
∑
∑
2 21( ) ( ) , 1/
1 1( ) ( ) or ( ) ( ), 2
( ) ( ) ( ) ( ) ( ) ( )
s sj nF t j nF ts n s s
n n ns
s s s sn ns s
s a s a
p t t nT c e e F TT
P n P F F nF FT T
x t x t p t X X P
π πδ
δ δ π
= − = = =
Ω = Ω − Ω = − Ω =
= ⇒ Ω = Ω ∗ Ω
∑ ∑ ∑
∑ ∑
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 36
Ban-limited signal
A signal is band-limited if there exists a finite radians frequency Ώ0 such that Xa(Ώ) is zero for |Ώ|> Ώ0.
The frequency F0= Ώ0 /2π is called the signal bandwidth in HzReferring to Fig.3.10, if π> Ώ0Ts , or Fs>2 F0 then
ssssa
s
jw
TTw
TTwjX
TeX ππ ≤
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 37
Sampling Principle
A band-limited signal xa(t) with bandwidth F0 can be reconstructed from its sample values x(n)=xa(nTs) if the sampling frequency Fs=1/Ts is greater than twice the bandwidth F0 of xa(t) , Fs >2 F0.
Otherwise aliasing would result in x(n). The sampling rate of 2F0 for an analog band-limited signal is called the Nyquist rate.
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 38
Example 3.17
Let xa(t)=exp(-1000|t|). Determine and plot its Fourier transform.
Ideal :
Using DTFT :
Selection of Δt : Xa(Ω)≒0 for Ω≧(2π)2000 or F≧2000. Therefore, Δt should be ≦1/4000. We set Δt=0.00005Selection of time period of xa(t) : -5m≦t≦5m since exp(-5)≒0.
( ) ( ) ( )j t j m ta a amX j x t e dt x m t e t+∞ − Ω − Ω Δ
−∞Ω = ≈ Δ Δ∑∫
2
0.002( )1 ( /1000)a
X Ω =+ Ω
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 39
Example 3.17
1. % Analog Signal2. Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t));3. %% Continuous-time Fourier Transform4. Wmax = 2*pi*2000; K = 500; k = 0:1:K; W = k*Wmax/K; 5. Xa = xa * exp(-j*t'*W) * Dt; Xa = real(Xa);6. W = [-fliplr(W), W(2:501)]; % Omega from -Wmax to
Wmax7. Xa = [fliplr(Xa), Xa(2:501)];8. subplot(2,1,1);plot(t*1000,xa);9. xlabel('t in msec.'); ylabel('xa(t)'); title('Analog Signal')10. subplot(2,1,2);plot(W/(2*pi*1000),Xa*1000);11. xlabel('Frequency in KHz'); ylabel('Xa(jW)*1000')12. title('Continuous-time Fourier Transform')
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 40
Example 3.17
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.2
0.4
0.6
0.8
1
t in msec.
xa(t)
Analog Signal
−2 −1.5 −1 −0.5 0 0.5 1 1.5 20
0.5
1
1.5
2
Frequency in KHz
Xa(
jW)*
1000
Continuous−time Fourier Transform
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 41
Example 3.18
Let xa(t)=exp(-1000|t|). Determine and plot its Fourier transform.
Ideal :
Using DTFT :
Selection of Δt : Xa(Ω)≒0 for Ω≧(2π)2000 or F≧2000. Therefore, Δt should be ≦1/4000. We set Δt=0.00005Selection of time period of xa(t) : -5m≦t≦5m since exp(-5)≒0.
( ) ( ) ( )j t j m ta a amX j x t e dt x m t e t+∞ − Ω − Ω Δ
−∞Ω = ≈ Δ Δ∑∫
2
0.002( )1 ( /1000)a
X Ω =+ Ω
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 42
Example 3.18a% Analog SignalDt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t));% Discrete-time SignalTs = 0.0002; n = -25:1:25; x = exp(-1000*abs(n*Ts));% Discrete-time Fourier transformK = 500; k = 0:1:K; w = pi*k/K;X = x * exp(-j*n'*w); X = real(X);w = [-fliplr(w), w(2:K+1)]; X = [fliplr(X), X(2:K+1)];subplot(2,1,1);plot(t*1000,xa);xlabel('t in msec.'); ylabel('x1(n)');title('Discrete Signal'); hold onstem(n*Ts*1000,x); gtext('Ts=0.2 msec'); hold offsubplot(2,1,2);plot(w/pi,X);xlabel('Frequency in pi units'); ylabel('X1(w)')title('Discrete-time Fourier Transform')
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 43
Example 3.18a
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.2
0.4
0.6
0.8
1
t in msec.
x1(n
)Discrete Signal
Ts=0.2 msec
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 10
2
4
6
8
10
Frequency in pi units
X1(
w)
Discrete−time Fourier Transform
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 44
Example 3.18b% Analog SignalDt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t));% Discrete-time SignalTs = 0.001; n = -5:1:5; x = exp(-1000*abs(n*Ts));% Discrete-time Fourier transformK = 500; k = 0:1:K; w = pi*k/K;X = x * exp(-j*n'*w); X = real(X);w = [-fliplr(w), w(2:K+1)]; X = [fliplr(X), X(2:K+1)];subplot(2,1,1);plot(t*1000,xa);xlabel('t in msec.'); ylabel('x1(n)');title('Discrete Signal'); hold onstem(n*Ts*1000,x); gtext('Ts=0.2 msec'); hold offsubplot(2,1,2);plot(w/pi,X);xlabel('Frequency in pi units'); ylabel('X1(w)')title('Discrete-time Fourier Transform')
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 45
Example 3.18b
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.2
0.4
0.6
0.8
1
t in msec.
x2(n
)
Discrete Signal
Ts=1 msec
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 10
0.5
1
1.5
2
2.5
Frequency in pi units
X2(
w)
Discrete−time Fourier Transform
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 46
Reconstruction
From the sampling theorem, the analog signal can be reconstructed from its sampled version through the process at the bottom if there is no aliasing effect.
Lowpass filter band-limited to the [-Fs/2,Fs/2] bandThe ideal interpolation is not practically feasible because the entire system is noncausal and hence not realizable.
Impulse train conversion
Ideal lowpass filter)(nx
)(txa
+−+++−+=−∑+∞
−∞=)()1()()0()()1()()( ss
ns TtxtxTtxnTtnx δδδδ
∑+∞
−∞=−=
nssa nTtFnxtx )]([sinc)()(
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 47
Reconstruction
Ideal lowpass filter is not practically realizable since the system is noncausalFig 3.14
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 48
Reconstruction
Derivation :
/ 2
/ 2
/ 2
/ 2
( ) { ( )} (1/ 2 ) ( )exp( )
From sampling theorem, we know ( ) ( ), / 2 .
( ) { ( )} (1/ 2 ) ( )exp( )
( ) ( / 2 ) ( ) exp( ( ))
s
s
s
s
s s a s sn
a s s s
a a a
a s a s sn
a
X FT x t x nT jn T
X T X
Then x t IFT X X j t d
x t T x nT j t nT d
x
π
π
π
Ω
−Ω
Ω
−Ω
Ω = = − Ω
Ω = Ω Ω ≤ Ω
= Ω = Ω Ω Ω
⇒ = Ω − Ω
⇒
∑
∫∑ ∫
/ 2exp( ( ))( ) ( / 2 ) ( )
( )2sin(( / 2)( ))( ) ( / 2 ) ( )
( )sin( ( ))( ) ( ) ( )sinc( ( ))
( )
s
ss a s
n s
s sa s a s
n s
s sa a s a s s s
n ns s
j t nTt T x nTj t nT
t nTx t T x nTt nT
F t nTx t x nT x nT F t nTF t nT
π
π
ππ
±Ω
Ω −=
−Ω −
⇒ =−
−⇒ = = −
−
∑
∑
∑ ∑
( ) ( )
( ) ( ) ( ) ( ) ( ) ( ) ( )
sn
s a a s a s sn n
p t t nT
x t x t p t x t t nT x nT t nT
δ
δ δ
= −
= = − = −
∑
∑ ∑
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 49
Practical D/A converters
Zero-order-hold (ZOH) interpolation:In this interpolation a given sample value is held for the sample interval until the next sample is received.It can be obtained by filtering the impulse train through an interpolating filter of the formThe resulting signal is a piecewise-constant (staircase) waveform which requires an appropriately designed analog post-filter for accurate waveform reconstruction.
0
ˆ ( ) ( ), ( 1)1 0
( )0 otherwise
a s s
s
x t x n nT n n Tt T
h t
= ≤ ≤ +
≤ ≤⎧= ⎨⎩
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 50
Practical D/A converters
Zero-order-hold (ZOH) interpolation:
ZOH Post-Filter)(nx )(txa)(ˆ txa
/ 2ˆ ( ) ( ) ( )
/ 2( )
a an
an
t Tx t x nT t nT rectT
t nT Tx nT rectT
δ −⎛ ⎞= − ∗ ⎜ ⎟⎝ ⎠
− −⎛ ⎞= ⎜ ⎟⎝ ⎠
∑
∑
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 51
Practical D/A converters
First-order-hold (FOH) interpolation: In this case the adjacent samples are joined by straight lines.
ˆ ( ) ( ) ( ) ( / )
( ) (( ) / )
a a s s sn
a s s sn
x t x nT t nT tri t T
x nT tri t nT T
δ= − ∗
= −
∑
∑
noncausal
equivalent to
ˆ ( ) ( ) [ ( 1) ( )], ( 1)at nTx t x n x n x n nT t n T
T−
= + + − ≤ ≤ +
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 52
Practical D/A converters
First-order-hold (FOH) interpolation: In this case the adjacent samples are joined by straight lines.
ˆ ( ) ( ) ( ) (( ) / )
( ) (( ) / )
a a s s s sn
a s s s sn
x t x nT t nT tri t T T
x nT tri t nT T T
δ= − ∗ −
= − −
∑
∑
causal
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 53
Practical D/A converters
First-order-hold (FOH) interpolation: In this case the adjacent samples are joined by straight lines.
1
1
ˆ ( ) ( ) ( ) ( )
( ) ( )
a a s sn
a s sn
x t x nT t nT h t
x nT h t nT
δ= − ∗
= −
∑
∑
causal and predictive FOH
⎪⎪⎪
⎩
⎪⎪⎪
⎨
⎧
≤≤−
≤≤+
=
otherwise0
21
01
)(1 sss
ss
TtTTt
TtTt
th
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 54
Practical D/A converters
Cubic-order-hold (COH) interpolationThis approach uses spline interpolation for a smoother, but not necessarily more accurate, estimate of the analog signal between samples.Hence this interpolation does not require an analog post-filterThe smoother reconstruction is obtained by using a set of piecewise continuous third-order polynomials called cubic splines
2 30 1 2 3( ) ( ) ( )( ) ( )( ) ( )( ) ,
for ( 1)where ( ), 0 ~ 3 are coefficients depended on sample values
a s s s
s s
i
x t n n t nT n t nT n t nTnT t n Tn i
α α α α
α
= + − + − + −≤ ≤ +=
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 55
Example 3.19
Reconstruction x1(t) in Example 3.18 by sinc()Ts = 0.0002; Fs = 1/Ts; n = -25:1:25; nTs = n*Ts;x = exp(-1000*abs(nTs));Dt = 0.00005;t = -0.005:Dt:0.005;xa = x * sinc(Fs*(ones(length(nTs),1)*t-nTs'*ones(1,length(t))));error = max(abs(xa - exp(-1000*abs(t))))
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
t in msec.
xa(t)
Reconstructed Signal from x1(n) using sinc function
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 56
Example 3.20
Reconstruction x2(t) in Example 3.18 by sinc()Ts = 0.0002; Fs = 1/Ts; n = -25:1:25; nTs = n*Ts;x = exp(-1000*abs(nTs));Dt = 0.00005;t = -0.005:Dt:0.005;xa = x * sinc(Fs*(ones(length(nTs),1)*t-nTs'*ones(1,length(t))));error = max(abs(xa - exp(-1000*abs(t))))
−5 −4 −3 −2 −1 0 1 2 3 4 5−0.2
0
0.2
0.4
0.6
0.8
1
1.2
t in msec.
xa(t)
Reconstructed Signal from x2(n) using sinc function
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 57
Example 3.21
Reconstruction x1(t) in Example 3.18 by ZOH and FOHZOH: stairs(nTs*1000,x); FOH: plot(nTs*1000,x);
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.2
0.4
0.6
0.8
1
t in msec.
xa(t)
Reconstructed Signal from x1(n) using zero−order−hold
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.2
0.4
0.6
0.8
1
t in msec.
xa(t)
Reconstructed Signal from x1(n) using first−order−hold
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 58
Example 3.22
Reconstruction x1(t) and x2(t) by cubic splineCubic spline : spline(nTs,x,t)
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.2
0.4
0.6
0.8
1
t in msec.
xa(t)
Reconstructed Signal from x1(n) using cubic spline function
−5 −4 −3 −2 −1 0 1 2 3 4 50
0.2
0.4
0.6
0.8
1
t in msec.
xa(t)
Reconstructed Signal from x2(n) using cubic spline function
FJU-EE – YUJL – Introduction DSP– Chapter3 - Page 59
HomeWork
Textbook: pp40 to pp79Exercises:
P3.2; P3.4; P3.14; P3.20; P3.22
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 1
Chapter 4
The bilateral z-TransformProperty of z-TransformInversion of z-TransformSystem representation in the z-domainSolution of difference equations
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 2
§4.0 Review
The discrete-time Fourier transform approach for representing discrete signals is using complex exponential sequence.Advantages for LTI system
It describes systems in the frequency domain using the frequencyresponse function H.The computation of the sinusoidal steady-state response is great facilitated by the use of H.Response to any arbitrary absolutely summable sequence x(n) can easily be computed in the frequency domain by multiplying the transform X and the frequency response H.
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 3
Review
Shortcomings to the FTThere are many useful signals in practice, such as u(n), nu(n), for which the DTFT does not exist.The transient response of a system due to initial conditions or due to changing inputs cannot be computed using the DTFT approach.
z-transform: To address the above two problems, z-transform is proposed which is an extension of the DTFT:
Bilateral (two-sided) version provides another domain in which a large class of sequence and systems can be analyzed.Unilateral (one-sided) version can be used to obtain system response with initial conditions or changing inputs.
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 4
§4.1 The Bilateral z-Transform
Definition of z-transform (ZT) and inversion of ZT (IZT):
where z is a complex variable and C is counterclockwise contour encircling the origin and lying in the ROC.
Region of convergence (ROC) : The set of z values for which X(z) exists is called the ROC and is given by
for some positive numbers Rx- and Rx+.
∫
∑−−
∞
−∞=
−
=Ζ=
=Ζ=
c
n
n
n
dzzzXj
zXnx
znxnxzX
11 )(21)]([)(
)()]([)(
π
+−
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 5
Comments
The complex variable z is called the complex frequency given by , where |z| is the attenuation and w is the real frequency;Since the ROC is defined in terms of the magnitude |z|, the shape of the ROC is an open ring. Note that Rx- may be equal to 0 and/or Rx+ could possibly be infinity;If Rx+
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 6
Example 4.1
Let .(This sequence is called a positive-time sequence). Then
Note: if X(z)=B(z)/A(z), then the roots of B(z) are called zeros and the roots of A(z) are called poles. A pole-zero diagram of X(z) is plotted in z-plane in which zeros are denoted by ‘o’ and poles by ‘×’.
1( ) ( ),0nx n a u n a= < < ∞
1 10 0
1
1( )1
;if 1 or :
nn n
RxRx
a zX z a zz az z a
a z a ROC a zz
∞ ∞−
−
+−
⎛ ⎞= = = =⎜ ⎟ − −⎝ ⎠
< > ⇒ < < ∞
∑ ∑
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 7
Example 4.2
Let .(This sequence is called a negative-time sequence). Then
2 ( ) ( 1),0nx n b u n b= − − − < < ∞
1 1
21
0
2
( )
1 1 11
: 0
n nn n
n
Rx Rx
b zX z b zz b
z zzb z bb
ROC z b
− − ∞−
−∞ −∞
∞
− +
⎛ ⎞ ⎛ ⎞= − = − = −⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠
⎛ ⎞= − = − =⎜ ⎟ −⎝ ⎠ −
⇒ ≤ <
∑ ∑ ∑
∑
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 8
Example 4.3
Let (This sequence is called a two-side sequence). Then using the above two examples.
3 1 2( ) ( ) ( ) ( ) ( 1)n nx n x n x n a u n b u n= + = − − −
1
30
( ) , 1: , 2 :
; 3 : 1 2
n n n n z zX z a z b z ROC z a ROC z bz a z b
z z ROC ROC ROCz a z b
∞ −− −
−∞
⎧ ⎫ ⎧ ⎫= − = > +
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 9
Properties of ROC
The ROC is always bounded by a circle since the convergence condition is on the magnitude |z|;The ROC for right-sided sequences (n=0, x(n) is a causal sequence)The ROC for left-sided sequences (n>n0, x(n)=0) is always inside of a circle of radius Rx+. (if n0
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 10
Properties of ROC
The ROC for finite-duration sequences(nn2, x(n)=0) is the entire z-plane. If n10, thenz=0 is not in the ROC;
Ex. ROC: entire Z-plane except z=∞
Ex.ROC: entire Z-plane except z=0, z=∞
Ex.ROC: entire Z-plane except z=0
The ROC cannot include a pole since X(z) diverges there;There is at least one pole on the boundary of a ROC of a rational X(z); The ROC is one contiguous region, the ROC does not come in pieces.
x(n) is finite
5 4 3 2( ) 3 5 3X z z z z z z= + + + +
2 1 1 2( ) 3 5 3X z z z z z− −= + + + +
1 2 3 4 5( ) 3 5 3X z z z z z z− − − − −= + + + +
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 11
§4.2 Important properties of the z-transform
Linearity:
Time Shifting:
Frequency Shifting:
Folding n ↔ inverting z
21:);()()]()([ 22112211 xx ROCROCROCzXazXanxanxaZ ∩+=+
xn ROCROCzXznnxZ :);()]([ 00
−=−
||:;)]([ abyscaledROCROCazXnxaZ x
n ⎟⎠⎞
⎜⎝⎛=
xROCInvertedROCzXnxX :);/1()]([ =−
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 12
Important properties of the z-transform
Complex conjugation
Differentiation in the z-domain
Multiplication
Convolution
xROCROCzXnxZ :);()]([*** =
xROCROCdzzdXznnxZ :;)()]([ −=
21:)/()(
21)]()([ 12121 xxC ROCROCROCdvvvzXvXj
nxnxZ ∩= ∫ −π
21:)()()](*)([ 2121 xx ROCROCROCzXzXnxnxZ ∩=
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 13
Example 4.4
Let and DetermineSolution:
From the definition of the z-transform we observe thatx1(n)={2,3,4} and x2(n)={3,4,5,6}
Then the convolution of the above two sequences will give the coefficients of the required polynomial product.x1=[2 3 4]; x2=[3 4 5 6];x3=conv(x1,x2)x3 =
6 17 34 43 38 24
211 432)(
−− ++= zzzX 3212 6543)(−−− +++= zzzzX
);()()( 213 zXzXzX =
FJU-EE – YUJL – Introduction DSP– Chapter4 - Page 14
Example 4.5
Let and DetermineS