Error using bitset fuction

1 回表示 (過去 30 日間)
kash
kash 2012 年 11 月 22 日
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

採用された回答

Walter Roberson
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 件のコメント
kash
kash 2012 年 11 月 22 日
Thanks walter also i tried A(:,end-2:end)=1;
it also returns error
Walter Roberson
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 ExchangeData Import and Analysis についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by