| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Signal Processing Toolbox |
| Contents | Index |
| Learn more about Signal Processing Toolbox |
| On this page… |
|---|
Exporting Coefficients or Objects to the Workspace Exporting Coefficients to an ASCII File |
You can save the filter either as filter coefficients variables or as a dfilt or mfilt filter object variable. (Note that you must have Filter Design Toolbox product installed to save as an mfilt.) To save the filter to the MATLAB workspace:
Select Coefficients from the Export As menu to save the filter coefficients or select Objects to save the filter in a filter object.
For coefficients, assign variable names using the Numerator (for FIR filters) or Numerator and Denominator (for IIR filters), or SOS Matrix and Scale Values (for IIR filters in second-order section form) text boxes in the Variable Names region.
For objects, assign the variable name in the Discrete Filter (or Quantized Filter) text box. If you have variables with the same names in your workspace and you want to overwrite them, select the Overwrite Variables check box.


To save filter coefficients to a text file,
The coefficients are saved in the text file that you specified, and the MATLAB Editor opens to display the file. The text file also contains comments with the MATLAB version number, the Signal Processing Toolbox version number, and filter information.
To save filter coefficients or a filter object as variables in a MAT-file:
Select Coefficients from the Export As menu to save the filter coefficients or select Objects to save the filter in a filter object.
For coefficients, assign variable names using the Numerator (for FIR filters) or Numerator and Denominator (for IIR filters), or SOS Matrix and Scale Values (for IIR filters in second-order section form) text boxes in the Variable Names region.
For objects, assign the variable name in the Discrete Filter (or Quantized Filter) text box. If you have variables with the same names in your workspace and you want to overwrite them, select the Overwrite Variables check box.
Click the Export button. The Export to a MAT-File dialog box appears.
See also Saving and Opening Filter Design Sessions.
You may want to use your designed filter in SPTool to do signal processing and analysis.
Note The magnitude response you see in SPTool will differ from the one in FDATool because the sampling frequency is preset at Fs = 2 when a filter is exported from FDATool to SPTool. |
Assign the variable name in the Discrete Filter (or Quantized Filter) text box. If you have variables with the same names in your workspace and you want to overwrite them, select the Overwrite Variables check box.
SPTool opens and the current FDATool filter appears in the Filter area list as the specified variable name followed by (Imported).
Note If you are using the Filter Design Toolbox product and export a quantized filter, only the values of its quantized coefficients are exported. The reference coefficients are not exported. SPTool does not restrict the coefficient values, so if you edit them in SPTool by moving poles or zeros, the filter will no longer be in quantized form. |
If you have the Simulink product installed, you can export a Simulink block of your filter design and insert it into a new or existing Simulink model.
You can export a filter designed using any filter design method available in FDATool.
After designing your filter, click the Realize Model sidebar button or select File > Export to Simulink Model. The Realize Model panel is displayed.

Select the Destination — Current to insert the block into the current (most recently selected) Simulink model or New to open a new model.
If you want to overwrite a block previously created from this panel, check Overwrite generated `Filter' block.
Note If you have Signal Processing Blockset product installed, a Build model using basic elements check box is included. If you deselect it, a Digital Filter block is created instead of a subsystem block, which uses separate subelements. See the Filter Realization Wizard and Choosing Between Filter Design Blocks in the Signal Processing Blockset documentation for information. |
If you select Build model using basic elements, you can select the desired optimization(s) for your block:
Optimize for zero gains — Removes zero-valued gain paths from the filter structure.
Optimize for unity gains — Substitutes a wire (short circuit) for gains equal to 1 in the filter structure.
Optimize for negative gains — Substitutes a wire (short circuit) for gains equal to -1 and changes corresponding additions to subtractions in the filter structure.
Optimize delay chains — Substitutes delay chains composed of n unit delays with a single delay of n.
Optimize for unity scale values — Removes multiplications for scale values equal to 1 from the filter sturcture.
The following illustration shows the effects of some of the optimizations:
Optimization Effects

Click the Realize Model button to create the filter block. The filter is implemented as a subsystem block using Sum, Gain, and Integer Delay blocks.

Note Note that if your filter is implemented using basic elements (Sum, Gain, and Delay blocks), inputs to the filter must be sample based. |
If you double-click the Simulink Filter block, the filter structure is displayed. The following figure shows the first section of the default four-section, direct form II filter.

You can also send your filter to a C header file or generate an M-file. The M-file contains code that replicates the filter you designed. See the following sections:
![]() | Importing a Filter Design | Generating a C Header File | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |