Products & Services Solutions Academia Support User Community Company

Learn more about Filter Design Toolbox   

Importing and Exporting Quantized Filters

Overview and Structures

When you import a quantized filter into FDATool, or export a quantized filter from FDATool to your workspace, the import and export functions use objects and you specify the filter as a variable. This contrasts with importing and exporting nonquantized filters, where you select the filter structure and enter the filter numerator and denominator for the filter transfer function.

You have the option of exporting quantized filters to your MATLAB workspace, exporting them to text files, or exporting them to MAT-files.

For general information about importing and exporting filters in FDATool, refer to FDATool: A Filter Design and Analysis GUI in the Signal Processing Toolbox User's Guide.

FDATool imports quantized filters having the following structures:

Example — Import Quantized Filters

After you design or open a quantized filter in your MATLAB workspace, FDATool lets you import the filter for analysis. Follow these steps to import your filter in to FDATool:

  1. Open FDATool.

  2. Select Filter > Import Filter from the menu bar.

    In the lower region of FDATool, the Design Filter pane becomes Import Filter, and options appear for importing quantized filters, as shown.

  3. From the Filter Structure list, select Filter object.

    The options for importing filters change to include:

    • Discrete filter — Enter the variable name for the discrete-time, fixed-point filter in your workspace.

    • Frequency units — Select the frequency units from the Units list under Sampling Frequency, and specify the sampling frequency value in Fs if needed. Your sampling frequency must correspond to the units you select. For example, when you select Normalized (0 to 1), Fs defaults to one. But if you choose one of the frequency options, enter the sampling frequency in your selected units. If you have the sampling frequency defined in your workspace as a variable, enter the variable name for the sampling frequency.

  4. Click Import to import the filter.

    FDATool checks your workspace for the specified filter. It imports the filter if it finds it, displaying the magnitude response for the filter in the analysis area. If it cannot find the filter it returns an FDATool Error dialog box.

To Export Quantized Filters

To save your filter design, FDATool lets you export the quantized filter to your MATLAB workspace (or you can save the current session in FDATool). When you choose to save the quantized filter by exporting it, you select one of these options:

Example — Export Coefficients or Objects to the Workspace

You can save the filter as filter coefficients variables or as a dfilt filter object variable. To save the filter to the MATLAB workspace:

  1. Select Export from the File menu. The Export dialog box appears.

  2. Select Workspace from the Export To list.

  3. Select Coefficients from the Export As list to save the filter coefficients or select Objects to save the filter in a filter object.

  4. For coefficients, assign variable names using the Numerator and Denominator options under Variable Names. For objects, assign the variable name in the Discrete or Quantized filter option. If you have variables with the same names in your workspace and you want to overwrite them, select the Overwrite Variables box.

  5. Click the OK button

    If you try to export the filter to a variable name that exists in your workspace, and you did not select Overwrite existing variables, FDATool stops the export operation and returns a warning that the variable you specified as the quantized filter name already exists in the workspace. To continue to export the filter to the existing variable, click OK to dismiss the warning dialog box, select the Overwrite existing variables check box and click OK or Apply.

Getting Filter Coefficients After Exporting

To extract the filter coefficients from your quantized filter after you export the filter to MATLAB, use the celldisp function in MATLAB. For example, create a quantized filter in FDATool and export the filter as Hq. To extract the filter coefficients for Hq, use

celldisp(Hq.referencecoefficients)

which returns the cell array containing the filter reference coefficients, or

celldisp(Hq.quantizedcoefficients

to return the quantized coefficients.

Example — Exporting as a Text File

To save your quantized filter as a text file, follow these steps:

  1. Select Export from the File menu.

  2. Select Text-file under Export to.

  3. Click OK to export the filter and close the dialog box. Click Apply to export the filter without closing the Export dialog box. Clicking Apply lets you export your quantized filter to more than one name without leaving the Export dialog box.

    The Export Filter Coefficients to Text-file dialog box appears. This is the standard Microsoft Windows save file dialog box.

  4. Choose or enter a directory and filename for the text file and click OK.

    FDATool exports your quantized filter as a text file with the name you provided, and the MATLAB editor opens, displaying the file for editing.

Example — Exporting as a MAT-File

To save your quantized filter as a MAT-file, follow these steps:

  1. Select Export from the File menu.

  2. Select MAT-file under Export to.

  3. Assign a variable name for the filter.

  4. Click OK to export the filter and close the dialog box. Click Apply to export the filter without closing the Export dialog box. Clicking Apply lets you export your quantized filter to more than one name without leaving the Export dialog box.

    The Export Filter Coefficients to MAT-file dialog box appears. This is the standard Microsoft Windows save file dialog box.

  5. Choose or enter a directory and filename for the text file and click OK.

    FDATool exports your quantized filter as a MAT-file with the specified name.

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS