Error using bitset fuction

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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

태그

질문:

2012년 11월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by