how can i convert decimal to hex in simulink?

조회 수: 31 (최근 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 CenterFile Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by