Azzera filtri
Azzera filtri

Invert bit vector ?

2 visualizzazioni (ultimi 30 giorni)
Henry Buck
Henry Buck il 5 Mar 2016
Modificato: Henry Buck il 18 Mar 2016
Hi,
I wonder how to make invert bit vector ?
*For example:*
I have A vector: A=[0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0] that mean 2 couples LSB are 1 0 1 0 and the rest are 01 0 1 0 1 0 1 0 1 0 1
And I want to invert it to B=[1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1] the result of the inverted vector should be MSB 1 0 1 0 and the rest couple bits 0 1 0 1 0 1 0 1 0 1 0 1.
Anyone knows how to do it ?
Thanks,
Henry

Risposta accettata

Stephen23
Stephen23 il 5 Mar 2016
>> A=[0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0];
>> B=[1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1];
>> C = [A(end-3:end),A(1:end-4)];
>> isequal(B,C)
ans =
1
  6 Commenti
Walter Roberson
Walter Roberson il 6 Mar 2016
Please format your entries.
Henry Buck
Henry Buck il 12 Mar 2016
Hi, Thank you for Your answer.
I think I did not understand your last comment.
Henry

Accedi per commentare.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by