Is it possible to pass and use hexadecimal values in simulink, without converting decimal?

20 vues (au cours des 30 derniers jours)
I am trying to use hexadecimal values in a model, without converting to decimal. Does simulink have hexadecimal supported blocks?

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Juin 2018
No. Hexadecimal is encoded as characters, and character is not a supported Simulink signal type.
You are permitted to pass around vectors of uint8 such as uint8('3e') = uint8([51 101]) and then char() the vector within a MATLAB Function Block or Level 2 S Function that wants the char version.
  2 commentaires
Dean DeBastiani
Dean DeBastiani le 5 Juin 2018
Thank you very much for your help, this is very useful.
Walter Roberson
Walter Roberson le 1 Sep 2020
Andy Bartlett's Answer reminds me that in R2019b, Simulink was enhanced to permit character vectors as a data type.
I cannot think of any special Simulink blocks that work with hex, though.

Connectez-vous pour commenter.

Plus de réponses (1)

Andy Bartlett
Andy Bartlett le 1 Sep 2020
If you are interested in entering parameters in hex or binary
For MATLAB integer types,
then as of R2019b, MATLAB has newly added the ability
to enter literals in hex and binary format.
myParam1 = 0x2A
myParam2 = 0b11111110
For fixed-point fi objects,
values can be entered in hex or binary like, so
myParam3 = fi([],0,8,3,'hex','AC')
myParam4 = fi([],0,8,3,'bin','01101001')
% To check the hex and binary
myParam3.hex
myParam4.bin
If you are interested in viewing the hex or binary representation of signals,
please see

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by