how to convert logical variable into hexadecimal number in Matlab?

5 views (last 30 days)
how to convert logical variable into hexadecimal number in Matlab?
  2 Comments
James Tursa
James Tursa on 17 Mar 2021
Please provide a short example of a logical input and what you want for a hex output.
Adam Danz
Adam Danz on 18 Mar 2021
The task seems odd to me, too. hex representation of 1/0 booleans is just '1','0'.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 17 Mar 2021
Edited: Adam Danz on 17 Mar 2021
hexstr = dec2hex([false true true false])
hexstr = 4×1 char array
'0' '1' '1' '0'
Or perhaps you want,
hexstr = string(double(([false true true false])))
hexstr = 1×4 string array
"0" "1" "1" "0"

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!