Filter Design Toolbox User's Guide

Download Filter Design Toolbox User's Guide

Post on 10-Feb-2017

215 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

  • Computation

    Visualization

    Programming

    For Use with MATLAB

    Users GuideVersion 2

    Filter DesignToolbox

  • How to Contact The MathWorks:

    508-647-7000 Phone

    508-647-7001 Fax

    The MathWorks, Inc. Mail3 Apple Hill DriveNatick, MA 01760-2098

    http://www.mathworks.com Webftp.mathworks.com Anonymous FTP servercomp.soft-sys.matlab Newsgroup

    support@mathworks.com Technical supportsuggest@mathworks.com Product enhancement suggestionsbugs@mathworks.com Bug reportsdoc@mathworks.com Documentation error reportssubscribe@mathworks.com Subscribing user registrationservice@mathworks.com Order status, license renewals, passcodesinfo@mathworks.com Sales, pricing, and general information

    Filter Design Toolbox Users Guide COPYRIGHT 2000 by The MathWorks, Inc.The software described in this document is furnished under a license agreement. The software may be usedor copied only under the terms of the license agreement. No part of this manual may be photocopied or repro-duced in any form without prior written consent from The MathWorks, Inc.

    FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation byor for the federal government of the United States. By accepting delivery of the Program, the governmenthereby agrees that this software qualifies as "commercial" computer software within the meaning of FARPart 12.212, DFARS Part 227.7202-1, DFARS Part 227.7202-3, DFARS Part 252.227-7013, and DFARS Part252.227-7014. The terms and conditions of The MathWorks, Inc. Software License Agreement shall pertainto the governments use and disclosure of the Program and Documentation, and shall supersede anyconflicting contractual terms or conditions. If this license fails to meet the governments minimum needs oris inconsistent in any respect with federal procurement law, the government agrees to return the Programand Documentation, unused, to MathWorks.

    MATLAB, Simulink, Stateflow, Handle Graphics, and Real-Time Workshop are registered trademarks, andTarget Language Compiler is a trademark of The MathWorks, Inc.

    Other product or brand names are trademarks or registered trademarks of their respective holders.

    Printing History: March 2000 New for Version 1.0 (online only)September 2000 First Printing Revised for Version 2 (Release 12)

    PHONEFAX

    MAIL

    INTERNET

    @E-MAIL

  • i

    Contents

    Preface

    What Is Filter Design Toolbox? . . . . . . . . . . . . . . . . . . . . . . . . . . xi

    Related Products List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii

    Using This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiNew Users of This Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiExperienced Users of This Toolbox . . . . . . . . . . . . . . . . . . . . . . . xivOrganization of This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

    Configuration Information . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

    Technical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii

    Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

    1Filter Design Toolbox Overview

    Filter Design Functions in the Toolbox . . . . . . . . . . . . . . . . . 1-4

    Quantization Functions in the Toolbox . . . . . . . . . . . . . . . . . 1-7Data Quantizers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8Quantized Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9Quantized Fast Fourier Transforms . . . . . . . . . . . . . . . . . . . . . 1-9

    Comparison to the Signal Processing Toolbox . . . . . . . . . . 1-11Filters in Signal Processing Toolbox . . . . . . . . . . . . . . . . . . . . 1-11Filters in Filter Design Toolbox . . . . . . . . . . . . . . . . . . . . . . . . 1-13

  • ii Contents

    Getting Started with the Toolbox . . . . . . . . . . . . . . . . . . . . . . 1-15Example - Creating a Quantized IIR Filter . . . . . . . . . . . . . . . 1-15Designing the IIR Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17Quantizing the IIR Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20

    Selected Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-28

    2Designing Advanced Filters

    The Optimal Filter Design Problem . . . . . . . . . . . . . . . . . . . . . 2-2Optimal Filter Design Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2Optimal Filter Design Solutions . . . . . . . . . . . . . . . . . . . . . . . . . 2-5

    Advanced FIR Filter Designs . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7gremez Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8

    Advanced IIR Filter Designs . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37iirlpnorm Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40iirlpnormc Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45iirgrpdelay Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51

    Robust Filter Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-59Filter Design Example That Includes Quantization . . . . . . . . 2-62

    Selected Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-68

    3Quantization and Quantized Filtering

    Binary Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3Digital Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3Quantized Filter Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4Quantized Filter Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4

  • iii

    Data Format for Quantized Filters . . . . . . . . . . . . . . . . . . . . . . . 3-5Quantized FFTs and Quantized Inverse FFTs . . . . . . . . . . . . . . 3-6

    Introductory Quantized Filter Example . . . . . . . . . . . . . . . . . 3-7Constructing an Eight-Bit Quantized Filter . . . . . . . . . . . . . . . 3-8Analyzing Poles and Zeros with zplane . . . . . . . . . . . . . . . . . . 3-10Analyzing the Impulse Response with impz . . . . . . . . . . . . . . . 3-10Analyzing the Frequency Response with freqz . . . . . . . . . . . . 3-11Noise Loading Frequency Response Analysis: nlm . . . . . . . . . 3-12Analyzing Limit Cycles with limitcycle . . . . . . . . . . . . . . . . . . 3-13

    Fixed-Point Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15Radix Point Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16Dynamic Range and Precision . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16Overflows and Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17

    Floating-Point Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18Scientific Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18The IEEE Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19The Exponent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19The Fraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19The Sign Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19Single-Precision Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20Double-Precision Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20Custom Floating-point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21Dynamic Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21Exceptional Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23

    4Working with Objects

    Objects for Quantized Filtering . . . . . . . . . . . . . . . . . . . . . . . . 4-2Constructing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3Copying Objects to Inherit Properties . . . . . . . . . . . . . . . . . . . . 4-4

    Properties and Property Values . . . . . . . . . . . . . . . . . . . . . . . . 4-5Setting and Retrieving Property Values . . . . . . . . . . . . . . . . . . . 4-5

  • iv Contents

    Setting Property Values Directly at Construction . . . . . . . . . . . 4-5Setting Property Values with the set Command . . . . . . . . . . . . 4-6Retrieving Properties with the get Command . . . . . . . . . . . . . . 4-8Direct Property Referencing to Set and Get Values . . . . . . . . . . 4-9

    Functions Acting on Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10

    Using Command Line Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11Command Line Help For Nonoverloaded Functions . . . . . . . . 4-11Command Line Help For Overloaded Functions . . . . . . . . . . . 4-11

    Using Cell Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13Indexing into a Cell Array of Vectors or Matrices . . . . . . . . . . 4-13Indexing into a Cell Array of Cell Arrays . . . . . . . . . . . . . . . . . 4-14

    5Working with Quantizers

    Quantizers and Unit Quantizers . . . . . . . . . . . . . . . . . . . . . . . . 5-2

    Constructing Quantizers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3Constructor for Quantizers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3

    Quantizer Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4Properties and Property Values . . . . . . . . . . . . . . . . . . . . . . . . . 5-4Settable Quantizer Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4Setting Quantizer Properties Without Naming Them . . . . . . . . 5-5Read-Only Quantizer Properties . . . . . . . . . . . . . . . . . . . . . . . . . 5-5

    Quantizing Data with Quantizers . . . . . . . . . . . . . . . . . . . . . . . 5-7Example Data-Related Quantizer Information . . . . . . . . . . . 5-7

    Transformations for Quantized Data . . . . . . . . . . . . . . . . . . . . 5-9

    Quantizer Data Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10

  • v

    6Working with Quantized Filters

    Constructing Quantized Filters . . . . . . . . . . . . . . . . . . . . . . . . 6-3Constructor for Quantized Filters . . . . . . . . . . . . . . . . . . . . . . . . 6-3Constructing a Quantized Filter from a Reference . . . . . . . . . . 6-4Copying Filters to Inherit Properties . . . . . . . . . . . . . . . . . . . . . 6-5Changing Filter Property Values After Construction . . . . . . . . 6-5

    Quantized Filter Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6Properties and Property Values . . . . . . . . . . . . . . . . . . . . . . . . . 6-6Basic Filter Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6Specifying the Filters Reference Coefficients . . . . . . . . . . . . . . 6-7Specifying the Quantized Filter Structure . . . . . . . . . . . . . . . . . 6-8Specifying the Data Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9Specifying All Data Format Properties at Once . . . . . . . . . . . . 6-10Specifying the Format Parameters with setbits . . . . . . . . . . . . 6-11Using normalize to Scale Coefficients . . . . . . . . . . . . . . . . . . . . 6-12

    Filtering Data with Quantized Filters . . . . . . . . . . . . . . . . . . 6-14

    Transformation Functions forQuantized Filter Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . 6-15

    7Working with Quantized FFTs

    Constructing Quantized FFTs . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3Constructor for Quantized FFTs . . . . . . . . . . . . . . . . . . . . . . . . . 7-3Copying Quantized FFTs to Inherit Properties . . . . . . . . . . . . . 7-4

    Quantized FFT Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6Properties and Property Values . . . . . . . . . . . . . . . . . . . . . . . . . 7-6Basic Quantized FFT Properties . . . . . . . . . . . . . . . . . . . . . . . . . 7-6Specifying the Data Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7Specifying All Data Format Properties at Once . . . . . . . . . . . . . 7-8Specifying the Format Parameters with setbits . . . . . . . . . . . . . 7-8

  • vi Contents

    Computing a Quantized FFT or Inverse FFT of Data . . . . 7-10

    8Quantized Filtering Analysis Examples

    Example Quantized Filtering of Noisy Speech . . . . . . . . . 8-3Loading a Speech Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3Analyzing the Frequency Content of the Speech . . . . . . . . . . . . 8-4Adding Noise to the Speech . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4Creating a Filter to Extract the 3000Hz Noise . . . . . . . . . . . . . 8-5Quantizing the Filter As a Fixed-Point Filter . . . . . . . . . . . . . . 8-8Normalizing the Quantized Filter Coefficients . . . . . . . . . . . . . 8-8Analyzing the Filter Poles and Zeros Using zplane . . . . . . . . . . 8-9Creating a Filter with Second-Order Sections . . . . . . . . . . . . . 8-11Quantized Filter Frequency Response Analysis . . . . . . . . . . . 8-12Filtering with Quantized Filters . . . . . . . . . . . . . . . . . . . . . . . . 8-13Analyzing the filter Function Logged Results . . . . . . . . . . . . . 8-14

    Example A Quantized Filter Bank . . . . . . . . . . . . . . . . . . . 8-16Filtering Data with the Filter Bank . . . . . . . . . . . . . . . . . . . . . 8-17Creating a DFT Polyphase FIR Quantized Filter Bank . . . . . 8-17

    Example Effects of Quantized Arithmetic . . . . . . . . . . . . 8-22Creating a Quantizer for Data . . . . . . . . . . . . . . . . . . . . . . . . . 8-22Creating a Fixed-Point Filter from a Quantized Reference . . . 8-22Creating a Double-Precision Quantized Filter . . . . . . . . . . . . . 8-23Quantizing a Data Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-23Filtering the Quantized Data with Both Filters . . . . . . . . . . . 8-23Comparing the Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24

  • vii

    9Quantization Tool Overview

    Switching FDATool to Quantization Mode . . . . . . . . . . . . . . . 9-3

    Getting Help for FDATool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5Context-Sensitive Help: The Whats This? Option . . . . . . . . . . . 9-5Additional Help for FDATool . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5

    Quantizing Filters in the Filter Design and Analysis Tool . 9-6To Quantize Reference Filters . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10To Change the Quantization Properties of Quantized Filters . 9-11

    Choosing Your Quantized Filter Structure . . . . . . . . . . . . . 9-12Converting the Structure of a Quantized Filter . . . . . . . . . . . . 9-12To Change the Structure of a Quantized Filter . . . . . . . . . . . . 9-13

    Scaling Transfer Function Coefficients . . . . . . . . . . . . . . . . 9-16To Scale Transfer Function Coefficients . . . . . . . . . . . . . . . . . . 9-16

    Scaling Inputs and Outputs of Quantized Filters . . . . . ....