Dividing vector into segment

2 次查看(过去 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 个)

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by