custum filter for biosignal
Show older comments
Dear all,
I have a custum made filter based on removing datapoints who are bigger than 3 times the std from the mean. I have to calculate the mean and over 30 datapoints. lets say n is the 35 value in a matrix, then I have to select the window from the 20 value till the 50 value. That does mean we don't can take our first 15 datapoints and have to start at the 15th point. How do I apply this in my code.
The code I have right now is:
parameter = y_day1;
s = 1800;
a = 1;
for k = 15:length(parameter)-s;
index = a:a+s;
Ytemp = parameter(index);
mean = mean(Ytemp);
stddev = std(Ytemp);
stddev = 3*stddev;
lowerbound = mean - stddev;
Ytemp(Ytemp < lowerbound) = NaN;
a = a+1;
y_day1_filtered(index) = Ytemp;
end
Answers (1)
Star Strider
on 25 Oct 2018
0 votes
If you have R2016a or later, you can use the movstd (link) function and its friends to calculate a sliding-window standard deviation.
To identify and remove the outliers, if you have R2015b (and the Signal Processing Toolbox), you can use the hampel (link) function, and in R2018b, the rmoutliers (link) function.
Categories
Find more on Smoothing and Denoising in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!