Filter löschen
Filter löschen

Obtain Values Greater Than Threshold For a Duration

12 Ansichten (letzte 30 Tage)
Ameen
Ameen am 20 Sep. 2022
Beantwortet: Walter Roberson am 20 Sep. 2022
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Sep. 2022
%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

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by