Obtain Values Greater Than Threshold For a Duration

12 次查看(过去 30 天)
Hello,
I have EMG data where I would like to see where the EMG is considered "Active". In order to be "Active" the signal must be above some threshold 'X' for 'Y' time points to be considered. (Ex. Above threshold value of 10 for at least 0.1 seconds). How may I find the indicies of values that are above the threshold for at least some given period of time.

采纳的回答

Walter Roberson
Walter Roberson 2022-9-20
%Fs is sampling frequency, use your actual frequency instead of the
%hard-coded one I give here
Fs = 24000;
threshold_duration = 0.1;
threshold_number_samples = ceil(threshold_duration * Fs);
mask = X(:).' > threshold;
mask2 = true(1, threshold_number_samples);
starts = strfind([false, mask], [false, mask2]);
stops = strfind([mask, false], [mask2, false]);
%now each starts(K) : stops(K) is indices of data above the threshold for
%sufficiently long

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by