实际上,我正在尝试将十六进制转换为bin。
a=hex2dec('ab32');
a=dec2bin(a);
%now I have a 1to1 char array of for example 1010101...
%I want to have an 1*16 array of 1 and 0's
我怎样才能做到这一点?
最佳答案
你可以这样做:
a=logical(a-'0')
例:
octave:224> a=hex2dec('ab32')
a = 43826
octave:225> a=dec2bin(a)
a = 1010101100110010
octave:226> a=logical(a-'0')
a =
1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 0
octave:227> whos a
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
a 1x16 16 logical
Total is 16 elements using 16 bytes
octave:228>
关于matlab - 如何在MATLAB中将'1 * 1 char'转换为逻辑向量?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11362504/