フィルターのクリア

how can i convert decimal to hex in simulink?

75 ビュー (過去 30 日間)
Ahmef Alhajsalem
Ahmef Alhajsalem 2019 年 2 月 22 日
コメント済み: Walter Roberson 2021 年 2 月 11 日
Hello everybody,
I wanted to convert a decimal value into HEX in Simulink using a matlab function. Unfortunately I get an error: Data 'y' (# 115) is inferred as a variable size matrix, while its specified type is something else. Can someone help please?
  1 件のコメント
JD Harwell
JD Harwell 2019 年 8 月 16 日
Did you find a solution to this? I am in need of the same.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 2 月 22 日
dec2hex() produces a character vector result. Character vectors cannot be carried as signals in Simulink. The closest you can get is to take send the codes for the characters and char() that later when you need to convert back to text.
y = dec2hex(u) + 0;
You should also be concerned about the signal length: dec2hex produces variable length output.
You might want to consider
y = uint8(dec2hex(u, 16) - '0');
changing the 16 to the number of digits appropriate for the situation.
  3 件のコメント
mohammad ahmad
mohammad ahmad 2021 年 2 月 10 日
how to convert decimal matrix(16*16) to hexa in matlab
Walter Roberson
Walter Roberson 2021 年 2 月 11 日
compose("%x", YourMatrix)

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by