Search code examples
matlabsimulink

Simulink: Bit extraction from 1-Byte Hex


I'm relatively new to Simulink and I am looking for a possibility to extract 1-3 specific bits from one byte. As far as I know the input format (bin, dec, hex) of the constant is irrelevant for the following!? But how can I say that the constant "1234" is hex and not dec?

In my model I use the "Constant Block" as my source (will be parametrised by a MATLAB variable which comes from a m-file). A further processing with the "Extract Bits Block" causes an error on incompatible data types.

Can someone help me to deal with this issue?

Greets, poeschlorn


Solution

  • Maybe this is not the most elegant solution, but I converted my input to decimal and then created a BCD representation of it via OR and AND logic blocks for further use.