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

 Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de Nov. de 2012

0 votos

bitset() is not defined to be able to change two bits at a time.
bitset(bitset(A, 1, 1), 2, 1)

2 comentarios

kash
kash el 22 de Nov. de 2012
Thanks walter also i tried A(:,end-2:end)=1;
it also returns error
Walter Roberson
Walter Roberson el 22 de Nov. de 2012
A is only of length 1, so end-2 would be trying to access column -1.
Indexing of numeric data does not access bits.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 22 de Nov. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by