MATLAB Answers

Dividing vector into segment

14 ビュー (過去 30 日間)
Uerm
Uerm 2019 年 10 月 3 日
コメント済み: Adam 2019 年 10 月 3 日
Hi,
I have a variable A which is a 1x48 cell containing 48 vectors of different lengths (say vector 1 is 2500x1, vector 2 is 2343x1 etc). I want to segment each of these vectors into different segments of length 128. How can I do that?

  1 件のコメント

Adam
Adam 2019 年 10 月 3 日
What do you want to do with them after? What do you want to happen to the bits left over when the length isn't divisible by 128?
You can just create a vector of start indices for each, e.g.
idx = cellfun( @(x) 1:128:numel(x), 'UniformOutput', false );
and then use those for future operations into the segments. Or to put them each into their own cell of a new cell array if you really want. Or, if you are going to discard any segments less than 128 length you can put them into a 128 x n matrix, n being however many segments you end up with.

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

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by