(Not recommended) Convert Binary to Base

您所在的位置:网站首页 matlabbi2de (Not recommended) Convert Binary to Base

(Not recommended) Convert Binary to Base

2023-02-01 08:45| 来源: 网络整理| 查看: 265

b1 = [0 1 0 1 1]; b2 = [1 1 1 0];

Convert the two binary arrays to decimal by using the bi2de function. Assign the most significant digit is the leftmost element. The output of converting b1 corresponds to 0 ( 2 4 ) + 1 ( 2 3 ) + 0 ( 2 2 ) + 1 ( 2 1 ) + 1 ( 2 0 ) = 1 1 , and b2 corresponds to 1 ( 2 3 ) + 1 ( 2 2 ) + 1 ( 2 1 ) + 0 ( 2 0 ) = 1 4 .

d1 = bi2de(b1,'left-msb')d1 = 11 d2 = bi2de(b2,'left-msb')d2 = 14

Assign the most significant digit is the rightmost element. The output of converting b1 corresponds to 0 ( 2 0 ) + 1 ( 2 1 ) + 0 ( 2 2 ) + 1 ( 2 3 ) + 1 ( 2 4 ) = 2 6 , and b2 corresponds to 1 ( 2 0 ) + 1 ( 2 1 ) + 1 ( 2 2 ) + 0 ( 2 3 ) = 7 .

d1 = bi2de(b1,'right-msb')d1 = 26 d2 = bi2de(b2,'right-msb')d2 = 7


【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3