Dividing vector into segment

조회 수: 3 (최근 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