How do I apply a standard deviation threshold when calculating a histogram from signal data in MATLAB
<p>I am calculating features from an EMG signal using MATLAB by segmenting the EMG signal into windows of 200 samples and then calculating the features of each window. </p>

<p>I need help trying to use a histogram feature please.</p>

<p>I can easily generate a vector of bins for one data window using the following code:</p>

<pre><code>    binCount = 9;
    [histBins, ~] = histcounts(dataWindow, binCount);
</code></pre>

<p>However, the experiment I am following states the histogram is divided into 9 bins along a 3 standard deviation (sigma) threshold. I am confused as to how the threshold fits in with generating the histogram bins. </p>

<p>Is a 3 sigma threshold calculated for each data window and the data points falling within that threshold used to generate the histogram? Example pseudo code:</p>

<pre><code>    for i = 1:numDataWindows
        dataWindow = windows(i);
        Calculate 3 standard deviations threshold using dataWindow
        Get data points from dataWindow that fall within threshold
        Generate histogram on data points within threshold
        ...
        Store histogram bins for later use
    end
</code></pre>

<p>Or is the 3 sigma threshold generated from the entire data signal, before windowing, so that the same threshold is then applied to each data window before generating each histogram?</p>