Давайте попробуем сделать это без петель.
%# random adjacency matrix
array = randi([0 1], [15 15 2200]);
%# get the size of the array
[n1,n2,n3] = size(array);
%# reshape it so that it becomes n3 by n1*n2
array2d = reshape(array,[],n3)';
%# make sure that every run has a beginning and an end by padding 0's
array2d = [zeros(1,n1*n2);array2d;zeros(1,n1*n2)];
%# take the difference. +1 indicates a start, -1 indicates an end
arrayDiff = diff(array2d,1,1);
[startIdx,startCol] = find(arrayDiff==1);
[endIdx,endCol] = find(arrayDiff==-1);
%# since every sequence has a start and an end, and since find searches down the columns
%# every start is matched with the corresponding end. Simply take the difference
persistence = endIdx-startIdx; %# you may have to add 1, if 42 to 46 is 5, not 4
%# plot a histogram - make sure you play with the number of bins a bit
nBins = 20;
figure,hist(persistence,nBins)
Edit:
Чтобы увидеть еще одно визуальное представление о сохранности ваших треков, позвоните
figure,imshow(array2d)
Здесь показаны белые полосы, где у вас есть последовательность ссылок, и общие шаблоны.