How can I convert a uint12 data to an int12 data in Simulink?

15 次查看(过去 30 天)
I have a 12 bit length 2's complement data that will need to be converted into int12 format in Simulink. The data conversion block in simulink only has output options of int8, int16, int32 or int64. Padding the 12 bit data will resultingly make the conversion inaccurate. Is there a way to convert this the uint12 to int12 in Simulink? Similarly I will have the same issue with converting a uint20 to int20 and uint24 to int24.

采纳的回答

Fangjun Jiang
Fangjun Jiang 2020-3-23
If you have the fixed point toolbox, then it is straightforward. Define your data types and then use them anywhere in Simulink, treating them like the built-in types such as int8 or uint8.
>> MyInt12=fixdt(1,12,0);
>> MyUint12=fixdt(0,12,0)
MyUint12 =
NumericType with properties:
DataTypeMode: 'Fixed-point: binary point scaling'
Signedness: 'Unsigned'
WordLength: 12
FractionLength: 0
IsAlias: 0
DataScope: 'Auto'
HeaderFile: ''
Description: ''

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by