matlab - How to operate with binary numbers as if they were a string -
what have is: assume x1= 0 0 1 , x2 = 0 1 0, given number l length give switch positions, let's l=2 (it changes randomly), i'd have switch de numbers this:
x1= 0 0 1; x1'= 0 0 0 x2 = 0 1 0; x2'= 0 1 1
what i've done far. each binary number code has value. said, ok, can make vector, position of vector code, , inside value, of course.
now, when need access string or bits or code, not sure how call it, i've been looking , i've found 2 functions(that didn't know of before):
dec2bin , de2bi. believe second 1 useful creates vector. , guess have vector position 1 l , l+1 n of both x1 , x2, , somehow switch both of (right i'm thinking of using 3rd vector it'd go: x1 xcopy, x2 x1, x1 x2 (the proper halfs, not of vector of course). i'm sure there better ways of doing particular switching, , whole thing.
could tell me of better or more useful way of approaching problem? in other languages feel it'd more natural, using map or struct guess, idea came matlab feels... unnecesary or redundant.
take @ bitset() in matlab's help. function allows change individual bit values in word.
Comments
Post a Comment