,如果它是隻爲時序元件可以使用一維過濾這樣的:
A = [-5 8000; 0 1000; 5 2000; 10 1000; 15 2000; 20 1000; 25 3000; 30 1000];
b = A(:,2);
% filtering with 2 elemnts vector. the imaginary part is to avoid
% false-positives from adding different numbers to the same sum
x = conv(b,[1;1j],'valid');
% find unique values and their number of occurrences
[C,ia,ic] = unique(x,'stable');
counts = histcounts(ic,[1:max(ic),inf]);
multiCounts = counts > 1;
% find the repeating patterns
patternFirstIdxs = ia(multiCounts);
patterns = [b(patternFirstIdxs),b(patternFirstIdxs + 1)];
,如果你想找到每個圖案外觀的所有出現在ia
或使用k = strfind(b,pattern)
爲他們每個人。
它不只是兩個連續的元素,可能會有多個值。但我會研究ia或k = strfind(b,pattern)。我很感謝你的迴應! –