making blocks using for loop

조회 수: 1 (최근 30일)
Raza
Raza 2014년 2월 17일
댓글: Raza 2014년 2월 19일
hi, i have number of bits (1 ans 0) and i want to have these bits in a block of 10 bits. let for example s=101010001110100101010010010001010 i want to put first 10 bits in b1 next ten bits in b2, next ten bits in b3 and the remaining bit in b4 with padding bits(to complete 10 bits in b4)

채택된 답변

Mischa Kim
Mischa Kim 2014년 2월 17일
편집: Mischa Kim 2014년 2월 17일
Raza, this should do the trick:
s = '101010001110100101010010010001010'
s0 = '000000000';
b = {};
for ii = 1:floor(length(s)/10)
ind = 10*(ii-1) + 1;
b{ii} = s(ind:ind + 9);
end
b{ii+1} = strcat(s(10*ii + 1:end),s0(1:10*(ii+1) - length(s)));
disp(b)
  댓글 수: 2
Raza
Raza 2014년 2월 17일
thanks man, got the idea
Raza
Raza 2014년 2월 19일
i got a problem that when i save these values in b1, b2 , b3 and so on. and retrieve it gives value instead of binary digits, so to solve i used bitget command but it only support 52 digits, while my requirement is 128

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by