Configure Blocks with Fixed-Point Parameters
Certain Simulink® blocks allow you to specify fixed-point numbers as the values of parameters used to compute the block's output, for example, the Gain parameter of a Gain block.
Note
S-functions and the Stateflow® Chart block do not support fixed-point parameters.
You can specify a fixed-point parameter value either directly by setting the value of
the parameter to an expression that evaluates to a fi
object, or indirectly by setting the value of the parameter to an
expression that refers to a fixed-point Simulink.Parameter
object.
Note
Simulating or performing data type override on a model with fi
objects requires a Fixed-Point Designer™ software license. See Sharing Fixed-Point Models for more information.
Specify Fixed-Point Values Directly
You can specify fixed-point values for block parameters using fi
objects. In the block dialog's
parameter field, simply enter the name of a fi
object or an
expression that includes the fi
constructor function.
For example, entering the expression
fi(3.3,1,8,3)
as the Constant value parameter for the Constant block specifies a signed fixed-point value of 3.3, with a word length of 8 bits and a fraction length of 3 bits.
Specify Fixed-Point Values via Parameter Objects
You can specify fixed-point parameter objects for block parameters using instances
of the Simulink.Parameter
class. To create
a fixed-point parameter object, either specify a fi
object as the parameter
object's Value
property, or specify the relevant fixed-point data
type for the parameter object's DataType
property.
For example, suppose that you want to create a fixed-point constant in your model. You could do this using a fixed-point parameter object and a Constant block as follows:
Enter the following command at the MATLAB® prompt to create an instance of the
Simulink.Parameter
class:my_fixpt_param = Simulink.Parameter
Specify either the name of a
fi
object or an expression that includes thefi
constructor function as the parameter object'sValue
property:my_fixpt_param.Value = fi(3.3,1,8,3)
Alternatively, you can set the parameter object's
Value
andDataType
properties separately. In this case, specify the relevant fixed-point data type using aSimulink.AliasType
object, aSimulink.NumericType
object, or afixdt
expression. For example, the following commands independently set the parameter object's value and data type, using afixdt
expression as theDataType
:my_fixpt_param.Value = 3.3; my_fixpt_param.DataType = 'fixdt(1,8,2^-3,0)'
Specify the parameter object as the value of a block's parameter. For example,
my_fixpt_param
specifies the Constant value parameter for the Constant block in the following model:The Constant block outputs a signed fixed-point value of 3.3, with a word length of 8 bits and a fraction length of 3 bits.