matlabbit-representation

Is there any way to reverse the order of bits in matlab


What I am trying is getting binary value of a number e.g

de2bi(234)

Which results me in having this answer :

 0     1     0     1     0     1     1     1

now what I want is that is its reverse order without changing its values like this :

11101010

i have tried bitrevorder() function but i am not having my desired answer. any help and suggestions will be appreciated.


Solution

  • Example:

    >>de2bi(234)
    
    ans =  0     1     0     1     0     1     1     1
    
    >> fliplr(ans)
    
    ans =
    
         1     1     1     0     1     0     1     0
    

    Use the function fliplr. It can be used to reverse the order of array.