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

15 ビュー (過去 30 日間)
Thamira Joy Valentine
Thamira Joy Valentine 2020 年 3 月 23 日
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: ''
  1 件のコメント
Thamira Joy Valentine
Thamira Joy Valentine 2020 年 3 月 23 日
Thank you very much! That does exactly what I need.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by