我试图处理大量数据,寻找周期性行为。换句话说,在两个值之间来回跳跃的数据。我尝试过许多不同的解决方案,但它们都给出了假阳性来识别行为。下面是一个例子,如果第一列是时间,第二列是高度:0 1000;5 2000;10 1000;15 2000;20 1000。在这个例子中,高度是在1000到2000英尺之间来回循环。如果有人能帮我一把,我会非常感激的。我在用MATLAB写东西。
发布于 2017-04-07 06:38:02
如果只适用于两个顺序元素,则可以使用1D筛选,如下所示:
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)。
https://stackoverflow.com/questions/43266051
复制相似问题