目录
dec2bin(code_pool_index-1,TBS)-'0'
bin2dec(num2str(code_pool_bits))
十进制>>二进制
dec2bin(code_pool_index-1,TBS)-'0'
TBS=3;
index=1:2^TBS;
code_pool=dec2bin(index-1,TBS)
code_pool_bits=dec2bin(index-1,TBS)-'0'
%由于matlab中索引从1开始,而3比特时存在000(十进制为0,对应索引值1,故需要加1)
%dec2bin(D,minDigits),其中minDigits为输出中的最小位数

二进制>>十进制
bin2dec(num2str(code_pool_bits))
TBS=3;
index=1:2^TBS;
code_pool=dec2bin(index-1,TBS)
code_pool_bits=dec2bin(index-1,TBS)-'0'
%由于matlab中索引从1开始,而3比特时存在000(十进制为0,对应索引值1,故需要加1)
%dec2bin(D,minDigits),其中minDigits为输出中的最小位数
src_idex = bin2dec(num2str(code_pool_bits))+1
本文介绍了如何使用MATLAB进行十进制与二进制之间的相互转换,并提供了具体的代码示例。针对不同场景,文章详细解释了如何将十进制数转换成指定位数的二进制数,以及如何将二进制数转回十进制数。
2739

被折叠的 条评论
为什么被折叠?



