Aug 21, 2013 #1 K knight_rider007 Newbie level 1 Joined Aug 21, 2013 Messages 1 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 6 hi all, I am new in matlab, I wish to read a textfile with 32bit unsigned values,I wish to read first bit of every value and need to write it on on another text file somebody pls give me suggestions
hi all, I am new in matlab, I wish to read a textfile with 32bit unsigned values,I wish to read first bit of every value and need to write it on on another text file somebody pls give me suggestions
Aug 21, 2013 #2 R rongo024 Advanced Member level 4 Joined Dec 29, 2008 Messages 111 Helped 21 Reputation 42 Reaction score 19 Trophy points 1,298 Location Bangladesh Activity points 1,806 filename = 'xxxx.txt' data = load(filename) data_bin = dec2bin(data) ... after that you can access by array indexing.. data_bin(i,end) is the first bit of the i-th value (located at index i).. or you can use mod(data(i), 2).. which gives whether the value is even or odd.. even means first bit is zero.. odd means first bit is one.
filename = 'xxxx.txt' data = load(filename) data_bin = dec2bin(data) ... after that you can access by array indexing.. data_bin(i,end) is the first bit of the i-th value (located at index i).. or you can use mod(data(i), 2).. which gives whether the value is even or odd.. even means first bit is zero.. odd means first bit is one.