Dividing vector into segment
3 views (last 30 days)
Show older comments
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 Comment
Adam
on 3 Oct 2019
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.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!