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
|