matlab session 5 l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
MATLAB Session 5 PowerPoint Presentation
Download Presentation
MATLAB Session 5

Loading in 2 Seconds...

play fullscreen
1 / 14

MATLAB Session 5 - PowerPoint PPT Presentation


  • 423 Views
  • Uploaded on

MATLAB Session 5. ES 156 Signals and Systems 2007 HSEAS. Prepared by Frank Tompkins. Outline . Fourier transforms in MATLAB DTFT computation Two methods An example Digital filtering in MATLAB FIR and IIR. Fourier Transform. Fourier Transforms Continuous Time Fourier Transform (CTFT)

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'MATLAB Session 5' - neviah


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
matlab session 5

MATLAB Session 5

ES 156 Signals and Systems 2007

HSEAS

Prepared by Frank Tompkins

outline
Outline
  • Fourier transforms in MATLAB
    • DTFT computation
      • Two methods
      • An example
  • Digital filtering in MATLAB
    • FIR and IIR
fourier transform
Fourier Transform
  • Fourier Transforms
    • Continuous Time Fourier Transform (CTFT)
    • Discrete Time Fourier Transform (DTFT)
fourier transform computation
Fourier Transform Computation
  • How to compute transforms on a computer?
  • CTFT is continuous, so that’s out
  • Can we compute DTFT?
dtft computation
DTFT Computation
  • Infinite length discrete time signals
    • DTFT defined on continuous frequency interval of length 2p; not computer friendly
  • What do we do?
    • Only deal with finite length signals
    • Recall: discrete time Fourier series has finitely many coefficients
    • So, we can use DTFS coefficients
  • More detail on this technique, called Discrete Fourier Transform, or DFT, later in the course
    • For now, just how to compute and plot “Fourier transform” in MATLAB
  • All the acronyms can be overwhelming, but we’ve seen almost all by now
dtft computation method 1
DTFT Computation (method 1)
  • Given finite length N signal, extend it to infinity by padding with zeros to make X[n]
    • DTFT X(ejw) has period 2p
    • Instead of storing X(ejw) for every possible w, we can store N evenly spaced values of w
    • Then, define X[k] = X(ej2pk/N)
    • The coefficients X[k] have period N
  • MATLAB command fft() computes X[k]
    • Side note: FFT (sorry, one more acronym: Fast Fourier Transform) is a popular algorithm that computes transforms quickly – not important now
dtft computation method 2
DTFT Computation (method 2)
  • Another perspective
    • Treat finite length N signal X[n] as a periodic (infinite length) signal Xp[n] with period N
    • Compute the DTFS of Xp[n], ak
    • Define X[k] = ak
      • Note: X[k] has period N, just like X[n]
  • These two approaches are equivalent
    • For now, think of DTFT/DFT in whichever way is easier for you (probably method 1)
example dtft of rectangular signal9
Example: DTFT of rectangular signal

x=[zeros(1,10) ones(1,7) zeros(1,10)];

y=fft(x);

figure;

subplot(2,1,1);

stem(x);

subplot(2,1,2);

plot(abs(y))

zero padding finer scale in fourier transform
Zero padding - finer scale in Fourier transform

y2=fft(x,64);

y3=fft(x,128);

figure;

subplot(3,1,1);

plot(abs(y))

subplot(3,1,2);

plot(abs(y2))

subplot(3,1,3);

plot(abs(y3))

fftshift
fftshift()
  • By default, MATLAB’s fft() command outputs X(ej2pk/N) for 0 <= 2pk/N < 2p
  • To get the output into the standard range of –p to p, use the fftshift() command:

my_xform = fftshift(fft(my_signal));

filters fir vs iir
Filters – FIR vs. IIR
  • A discrete time LTI filter can be expressed as a difference equation
  • If all a(i)’s are zero except a(1) we call it FIR, otherwise it’s IIR
  • MATLAB: z = filter(b,a,x)
filter example
Filter example
  • Input: x[n] is the rectangular signal from before
  • The difference equation describing the filter is

a=[1,-1];

b=1;

z=filter(b,a,x)

figure;

subplot(2,1,1);

stem(x);

subplot(2,1,2)

stem(z);