making a block of fix length

1 回表示 (過去 30 日間)
Raza
Raza 2014 年 2 月 17 日
コメント済み: Image Analyst 2014 年 2 月 17 日
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)

採用された回答

Image Analyst
Image Analyst 2014 年 2 月 17 日
b1 = s(1:10);
b2 = s(11:20);
and so on.
  2 件のコメント
Raza
Raza 2014 年 2 月 17 日
need to do with for loop
Image Analyst
Image Analyst 2014 年 2 月 17 日
But you don't have anything indexed - you have separately named variables b1, b2, b3, etc. If you want a loop you'll need to index them
count = 1;
b = zeros(1, 10);
for k = 1 : 10 : length(s)
index1 = k * 10;
index2 = index1 + 9;
b(count, :) = s(index1:index2);
count = count + 1;
end
and s must be a multiple of 10 elements long.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by