How can I convert a uint12 data to an int12 data in Simulink?
16 views (last 30 days)
Show older comments
Thamira Joy Valentine
on 23 Mar 2020
Commented: Thamira Joy Valentine
on 23 Mar 2020
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.
0 Comments
Accepted Answer
Fangjun Jiang
on 23 Mar 2020
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: ''
More Answers (0)
See Also
Categories
Find more on String in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!