루프없이 이것을 시도해 보겠습니다.
%# 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)
편집 :
당신이 링크의 순서이 곳이 흰색 줄무늬를 보여줍니다
figure,imshow(array2d)
전화, 트랙의 지속성의 또 다른 시각적 표현을 보려면, 그리고 것 전반적인 패턴을 보여줍니다.
@Jonas : 코드를 좀 더 쉽게 읽을 수 있도록 포맷했습니다. – Amro
@Amro : 죄송합니다. 편집하는 동안 수정 사항을 제출해야합니다. 다시 시도해 주시겠습니까? – Jonas
죄송합니다 .. 다시 시도해보십시오! – Amro