A '0' '1' () , , strsplit, .
N = 3 - . :
Duration = cellfun(@numel, strsplit(char((A>0)+'0'), repmat('0',1,N)));
, N . , A = [1 2 3 0 0 0 0 4 5] Duration = [3 3], .
N , :
Duration = cellfun(@numel, regexp(char((A>0)+'0'), [repmat('0',1,N) '+'], 'split'));
A = [1 2 3 0 0 0 0 4 5] Duration = [3 2].