Fixed-Point Blockset |
 |
num2fixpt
Quantize a value using a Fixed-Point Blockset representation
Syntax
outValue = num2fixpt(OrigValue,FixPtDataType,FixPtScaling,...
RndMeth, DoSatur)
Description
num2fixpt
casts a real-world value represented in floating-point doubles, OrigValue
, as a fixed-point number, outValue
.
OrigValue
|
Identifies the real-world value to be cast to fixed-point.
|
FixPtDataType
|
Designates the desired fixed-point data type of outValue .
|
FixPtScaling
|
Indicates the scaling of the output in either Slope or [Slope Bias] format.
|
RndMeth
|
Specifies the rounding technique to be used on the output. If FixPtDataType is FLOAT , then RndMeth is ignored.
|
DoSatur
|
Indicates whether the output should be saturated to the minimum or maximum representable value upon underflow or overflow. If FixPtDataType is FLOAT , then DoSatur is ignored.
|
Example
The command
num2fixpt(Pi,sfix(8),2^-5,'Nearest',on)
returns Pi
as a signed 8-bit fixed-point number with scaling of 2^-5. Rounding is towards the nearest representable value, and overflows saturate.
See Also
fixptbestexp
, fixptbestprec
, float
, sfix
| fxptdlg | | sfix |  |