gpt4 book ai didi

matlab - 在 Matlab 时间序列数据中查找阈值交叉,然后在找到下一个阈值交叉之前忽略后续交叉 60 秒

转载 作者:行者123 更新时间:2023-12-02 03:53:57 25 4
gpt4 key购买 nike

这解释起来有点复杂。我的时间序列数据格式如下:https://docs.google.com/spreadsheets/d/1B8mN0uD-t4kQr2U20gS713ZFHN6IgGB7OMR3-pqJjrw/edit?usp=sharing

该数据代表以 0.01 秒间隔记录的电压。绘制后看起来像这样:

http://i.imgur.com/yatlBLt.jpg .

本质上,我想做的是找到每个非常窄的对中第一个峰值出现的时间(即~.1、.75、1.6等)。

时间值位于单独的数组中,但索引值(行号)在两个集合之间相对应。

关于如何做到这一点有什么想法吗?

我最初的尝试是来自 matlab 手册的类似内容

function [edges2] = risingEdge2(time, data)
threshold = 0.4;
offsetData = [data(2:end); NaN];
edges2 = find(data < threshold & offsetData > threshold);
end

我想不出一个好方法来忽略第一个峰值后的 n 秒...我也得到了比预期更多的峰值...可能是因为噪声数据。

最佳答案

以下方法似乎适用于给定的数据。

%// Define parameters
window_size = 200;
stepsize = 0.4; %// to be used for quantizing data into three levels - 0, 0.4, 0.8

%// Perform a sliding max to get rid of the dips within the spikes
slmax_data = nlfilter(data,[window_size 1],@max);

enter image description here

%// Quantize sliding max data to three levels as the plot seem to suggest
quantized_slmax_data = round((slmax_data-min(slmax_data))./stepsize);

enter image description here

如果放大上图,您会看到高峰周围的壁架 -

enter image description here

%// Get sliding mode to get rid of the short ledges around the high peaks
slmax_mode_data = nlfilter(quantized_slmax_data,[window_size 1],@mode);

enter image description here

%// Finally, find the indices where the mode data jump from 0 to 1 only, which
%// correspond to the start of spikes
index = find(diff(slmax_mode_data)==1)+window_size/2;

输出 -

index =
682
8048
16487
24164
31797

关于matlab - 在 Matlab 时间序列数据中查找阈值交叉,然后在找到下一个阈值交叉之前忽略后续交叉 60 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26803359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com