Convert binary integers to quaternary integers
显示 更早的评论
Is it possible to convert binary integers generated using a randi() to quaternary integers (0-3) by taking two bits from the source and combining them?
采纳的回答
更多回答(1 个)
Walter Roberson
2012-5-17
0 个投票
Yes. B1*2 + B2
2 个评论
M
2012-5-17
Walter Roberson
2012-5-17
If you need to, put the 4 possible results into a vector, and index the vector at B1*2 + B2 + 1
类别
在 帮助中心 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!