1 / 14

MATLAB Session 5

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)

neviah
Télécharger la présentation

MATLAB Session 5

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MATLAB Session 5 ES 156 Signals and Systems 2007 HSEAS Prepared by Frank Tompkins

  2. Outline • Fourier transforms in MATLAB • DTFT computation • Two methods • An example • Digital filtering in MATLAB • FIR and IIR

  3. Fourier Transform • Fourier Transforms • Continuous Time Fourier Transform (CTFT) • Discrete Time Fourier Transform (DTFT)

  4. Fourier Transform Computation • How to compute transforms on a computer? • CTFT is continuous, so that’s out • Can we compute DTFT?

  5. 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

  6. 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

  7. 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)

  8. Example: DTFT of rectangular signal • Rectangular signal

  9. 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))

  10. Example: DTFT of rectangular signal

  11. 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))

  12. 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));

  13. 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)

  14. 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);

More Related