Error using bitset fuction
1 次查看(过去 30 天)
显示 更早的评论
i have value A=46;
i used bitset function to change the second bit ,i get abswer ,but how to change the last 2 bits ,i tried using
X=bitset(A,1:2,1); setting last two bits to one
please help
0 个评论
采纳的回答
Walter Roberson
2012-11-22
bitset() is not defined to be able to change two bits at a time.
bitset(bitset(A, 1, 1), 2, 1)
2 个评论
Walter Roberson
2012-11-22
A is only of length 1, so end-2 would be trying to access column -1.
Indexing of numeric data does not access bits.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!