使用 MATLAB 识别循环行为

Identifying cyclical behavior using MATLAB

我正在尝试处理大量数据以寻找周期性行为。换句话说,数据在两个相应值之间来回跳跃。我尝试了许多不同的解决方案,但它们都给出了识别行为的误报。如果第一列是时间,第二列是高度,这是我正在寻找的示例:[0 1000; 5 2000; 10 1000; 15 2000; 20 1000]。在此示例中,高度在 1000 和 2000 英尺之间来回循环。如果有人能帮我一把,我将不胜感激。我正在用 MATLAB 编写。

如果仅针对 两个 顺序元素,您可以像这样使用一维过滤:

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)