从 Matlab 中的音频流向量中,我试图确定在时间序列数据中多次发生的声音事件的开始和结束时间。
我是 Matlab 的新手,但是我已经编写了识别事件峰值和位置的代码,但是,我需要相对于用户定义的阈值获取事件的开始,该阈值发生在峰值之前的几十毫秒.
这是我目前正在使用的代码:
function [emg] = calcPeaks(EMG, thresh)
%Rectify and downsample data
emg = resample(abs(hilbert(EMG)),1000,10000);
%Low Pass Filter
[b,a]=butter(8,0.01,'low');
emg=filtfilt(b,a,emg);
%Plot the processed vector
plot (emg); hold on;
%Find maximum for each Peak and Location
[pks,locs] = findpeaks(emg(1:end-2000),'minpeakheight',thresh);
plot(locs, emg(locs), 'ko'); hold on;
%Find Crossings above threshold
[FindCross] = find(emg(1:end-2000) > thresh);
[Gaps] = find(diff(FindCross)> thresh);
plot(FindCross, emg(FindCross), 'ro');
plot(Gaps, emg(Gaps), 'bo');
我试图发布数据的图像,但我没有足够的声誉:(