Split an array in MATLAB

Viewed 6488

I have an array of integer numbers, and I want to split this array where 0 comes and a function that give me points of split.

Example: Array : 0 0 0 1 2 4 5 6 6 0 0 0 0 0 22 4 5 6 6 0 0 0 4 4 0

The function must return these numbers:

[ 3 10 ;14 20 ;22 25 ]

These numbers are index of start and end of nonzero numbers.

3 Answers
Related