我有一个关于 findpeaks 的问题。我想用它来检测信号时间序列(信号 1)中的峰值。这工作正常,但我也有代理数据,作为重要的阈值,等长(信号 2)。我现在想在信号 1 上使用 findpeaks,但前提是信号 1 在该时间点大于信号 2。我尝试使用 findpeaks 的常规属性,但到目前为止没有任何效果......这是我现在所拥有的:
GPDC
是 9x9x512 双倍。Dim 1 包含通过多变量自回归模型在 xi - xj 方向上估计的部分有向相干值,Dim 2 包含 xj -xi 的相同值,Dim 3 表示频率区间的数量。eEPDCsth
是一个包含相应代理数据的 9x9x512 双精度值。f
是一个包含频率值的 1x512 双精度值。我现在认为, >= 参考不起作用,因为它不是特定于时间的,即它不会逐点比较信号,而是整体比较。这是我认为的主要问题...
Sz=9;
for i=1:Sz
for j=1:Sz
if squeeze(GPDC(i,j,:)) >= squeeze(eEPDCsth(i,j,:))
[pks_1{i,j},locs_1{i,j}] = findpeaks(squeeze(GPDC(i,j,:)),f,'npeaks',5,'MinPeakHeight', .1);
end
end
end
这是一个示例,应该可以完成您所描述的内容。您没有指定 'f' 向量的实际内容,因此在此示例中我将其设置为 1:512
% data for testing
GPDC = rand(9,9,512);
eEPDCsth = rand(9,9,512);
f = 1:512; % the value of the 'f' vector wasn't specified in question
Sz=9;
for i=1:Sz
for j=1:Sz
% find the 'raw' peaks below thresholding
[peak_val_raw, peak_indices_raw] = findpeaks(squeeze(GPDC(i,j,:)),'npeaks',5,'MinPeakHeight', .1);
% only keep peaks that are above the corresponding threshold value
peaks_above_threshold = squeeze(GPDC(i,j,peak_indices_raw)) > squeeze(eEPDCsth(i,j,peak_indices_raw));
peak_values_thresholded = peak_val_raw(peaks_above_threshold);
peak_indices_thresholded = peak_indices_raw(peaks_above_threshold);
pks_1{i,j} = peak_values_thresholded;
% index into 'f' vector to match code in original question
locs_1{i,j} = f(peak_indices_thresholded);
end
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句