フィルターのクリア

Create fi object from Simulink data type

1 回表示 (過去 30 日間)
Eirik Nordeng
Eirik Nordeng 2024 年 3 月 12 日
回答済み: Andy Bartlett 2024 年 3 月 12 日
I am working on documenting a fixed point model and would like to automate as much as possible. I have a script that lists all inputs and outputs and their compiled data types (e.g. sfix27_En29). I would now like to create a fixed point object (fi()) using the data type provided from my simulink model in order to gain access to functions provided with the fixed point object.
Is there a built-in function for creating a fi() object using the Simulink data type descriptor?

採用された回答

Andy Bartlett
Andy Bartlett 2024 年 3 月 12 日
Hi
Create a numerictype object from the type name.
Then create a fi object using the numerictype as the second input argument, and the value as the first input argument.
The most general tool to create the numerictype object would be
fixed.extractNumericType
but some alternates are shown below.
See
help fixed.extractNumericType
to learn the many different inputs that can be used to create a numerictype object.
nt = fixed.extractNumericType('sfix27_En29')
nt = DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 27 FractionLength: 29
val3 = fi( 1/30, nt )
val3 =
0.0333 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 27 FractionLength: 29
Alternates
nt2 = numerictype('sfix27_En29')
nt2 = DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 27 FractionLength: 29
nt3 = fixdt('sfix27_En29')
nt3 =
NumericType with properties: DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Signed' WordLength: 27 FractionLength: 29 IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: ''
valMaxFiniteRepresentable = upperbound(nt)
valMaxFiniteRepresentable =
0.1250 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 27 FractionLength: 29
valMinFiniteRepresentable = lowerbound(nt)
valMinFiniteRepresentable =
-0.1250 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 27 FractionLength: 29

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFPGA, ASIC, and SoC Development についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by