How do I read change values in a binary vector with some other values ?

I have a binary vector of length 656, I want to take a chunk of 16 bits from the vector at a time and read it. In that 16 bit I want to replace each 1 bit with a sequence of 0 1 bits of length 64 and 0 with 1 0 bits length 64. Any help regarding implementing the loop you be appreciated highly.

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 19 日

0 投票

bittable = {repmat([0 1], 1, 32), repmat([1 0], 1, 32)};
for K = 1 : 16 : 656
thisbitvec = YourBitVector(K:K+15);
chunk = cell2mat(bittable(thisbitvec + 1));
now do something with the chunk
end

1 件のコメント

Haseeb Mufti
Haseeb Mufti 2015 年 10 月 19 日
Thanks for the answer it is very helpful.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2015 年 10 月 19 日

コメント済み:

2015 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by