# how to recover the bits using matlab

Status
Not open for further replies.

#### chitra ranganath

##### Member level 2
hi can pls somebody help me in solving this doubt
z= 10101010 1 1 0 10101111 0 11111111
here in this ive stored some bits with spaces in reg z
the logic is after reading 1st 8 bits ill see wat is next bit.
if it is '1' i should get output as previous same 8 bits.
else if bit is '0' i shd get next 8 bits.
so output for this sequence above must be

out= 10101010
10101010
10101010
10101111
11111111
pls help me out
for j=1:1:8
res(j)=zb(j);
end
disp (res);

for i=9:1:nbits
if(zb(i)==' ')
res='\n'
end
if(zb(i+2)=='1')
res(i)=zb(i-12);
elseif(zb(i+9)=='0')
res(i)=zb(i+12);
end
end
disp(res); this is some code i wrote

Status
Not open for further replies.