Simulink data type conversion, single to uint16.
古いコメントを表示
Hello,
I'm using simulink and I need to convert from a single to a uint16.
Could a kind soul kindly explain why the output of a single (with range 0-2pi) equates to an uint16 of zero?
Here is an example:

And here is the output of that example:

There are a number of uint16 signals in my model with range 0-4000 (I am reading from sevreral ADC). All behave as expected. Just this conversion, in this instance.
5 件のコメント
Daniel
2024 年 9 月 18 日
What is happening to that value downstream? Are you generating code? Is it being used for trigonometry?
Walter Roberson
2024 年 9 月 18 日
Are you using the Data Type Conversion Block? https://www.mathworks.com/help/simulink/slref/datatypeconversion.html
Walter Roberson
2024 年 9 月 18 日
I would expect single range 0 to 2*pi to convert to uint16 values 0, 1, 2, 3, 4, 5 or 6.
Data type conversion does not do any scaling to match the range. For example it is not going to scale 0 to 2*pi to 0 to 62831
Jamie
2024 年 9 月 25 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


