【问题标题】:Find threshold cross in Matlab timeseries data, then ignore subsequent crosses for 60 seconds before finding next threshold cross在 Matlab 时间序列数据中找到阈值交叉,然后在找到下一个阈值交叉之前忽略后续交叉 60 秒
【发布时间】:2015-01-04 08:52:19
【问题描述】:

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

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

基本上我想做的是找到每个非常窄的对中第一个峰值出现的时间(即在 ~.1、0.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 秒内,我想不出一个忽略的好方法……我也得到了比预期更多的峰值……可能是因为噪声数据。

【问题讨论】:

  • 您有没有尝试过但遇到问题的方法?
  • 信号处理工具箱能用吗?
  • @AnonSubmitter85 刚刚更新了我的尝试
  • 好吧,sig proc 工具箱中有findpeaks 命令,但我不知道这是否适用于方脉冲序列顶部的上下性质。这必须有多普遍和稳健?如果您对简单的阈值处理感到满意,那么您可以设置阈值并忽略高于阈值超过 N 秒的区域。不过,这样做有点骇人听闻。如果窄信号是周期性的,你能在频域中隔离它们吗?再一次,方脉冲序列可能会让这很难做到。
  • 因此,如果您只设置阈值,您将得到一个由 1 和 0 组成的向量。找出每个连续跨度 1 的长度并丢弃那些太长的。剩下的将是更窄的冲动。

标签: matlab threshold


【解决方案1】:

在这里 -- 找到所有上升沿,然后找到那些非常接近的并取第一个。

rising_edges = find(diff(data > .3) > 0);
first_of_paired_edges = find(diff(time(rising_edges)) < 500);

first_rising_edge_times = time(rising_edges(first_of_paired_edges));

然后您可以将边缘向上滑到峰顶。

first_peak_times = time(arrayfun( @(n) n+find(diff(data(n+[0:1000]) < 0, 1, 'first'), 
                        rising_edges(first_of_paired_edges));

【讨论】:

    【解决方案2】:

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

    %// 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);
    

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

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

    %// 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);
    

    %// 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
    

    【讨论】:

    • 哦,我喜欢这个解决方案。我无法让它工作。我对 nlfilter 不熟悉...对于“function_handle”类型的输入参数,我不断收到错误未定义函数“nlfilter”。编辑:我想我需要安装图像处理工具箱。
    • @user3746901 是的图像处理。使用这些代码需要工具箱!告诉我进展如何?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 2015-12-14
    相关资源
    最近更新 更多