Products & Services Solutions Academia Support User Community Company

Example: Conversions and Arithmetic Operations

This example uses the Discrete FIR Filter block to illustrate when parameters are converted from a double to a fixed-point number, when the input data type is converted to the output data type, and when the rules for addition, subtraction, and multiplication are applied. For details about conversions and operations, refer to Parameter and Signal Conversions and Rules for Arithmetic Operations.

Suppose you configure the Discrete FIR Filter block for two outputs, where the first output is given by

and the second output is given by

Additionally, the initial values of and are given by 0.8 and 1.1, respectively, and all inputs, parameters, and outputs have binary-point-only scaling.

To configure the Discrete FIR Filter block for this situation, on the Main pane of its dialog box, you must specify the Numerator coefficients parameter as [13 11 -7; 6 -5 0] and the Initial states parameter as [0.8 1.1], as shown here.

Similarly, configure the options on the Data Type Attributes pane of the block's dialog box to appear as follows:

Parameter conversions and block operations are given below in the order in which they are carried out by the Discrete FIR Filter block:

  1. The Numerator coefficients parameter is converted offline from doubles to the Numerator coefficients data type value using round-to-nearest and saturation.

    The Initial states parameter is converted offline from doubles to the input data type using round-to-nearest and saturation.

  2. The coefficients and inputs are multiplied together for the initial time step for both outputs. For y1(0), the operations , , and are performed, while for y2(0), the operations and are performed.

    The results of these operations are stored as Product output.

  3. The sum is carried out in Accumulator. The final summation result is then converted to Output.

  4. Steps 2 and 3 are repeated for subsequent time steps.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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