필터 지우기
필터 지우기

Removing spikes with standard deviation

조회 수: 3 (최근 30일)
Gabriel Luca Pugliese Borges
Gabriel Luca Pugliese Borges 2022년 3월 21일
댓글: Star Strider 2022년 3월 21일
Hey.
I'm trying to remove some spikes in a water current data using nanmean and nanstd.
To do it, i created this script:
Data3=Data2(:,:,5:6); %Data2 is the real data matrix. To don't take risks, i created a copy and work on it.
it=2;
[~,col,page]=size(Data3);
for p=1:page
for c=1:col
for i=it+1:length(Data3)-it;
x=nanmean(Data3(i-it:i+it,c,p));
y=nanstd(Data3(i-it:i+it,c,p));
if Data3(i,c,p)>x+3*y || Data3(i,c,p)<x-3*y;
Data3(i,c,p)=NaN;
end
end
end
end
%clear p c r x y z k row col page it
After running it, i did a plot to check if the original data(Data2) are now diferent from the one with no spikes(Data3)
plot(Data2(:,5,5))
hold
plot(Data3(:,5,1))
Despite this, i realized that they still equivalents and perfectly equals.
Why my code isn't working?
I appreciate any kind of help on it. Thanks to you all. This community is one of the best in the world!

채택된 답변

Star Strider
Star Strider 2022년 3월 21일
Without the data, it is not possible to determine the reason the code does not work.
See if the rmoutliers function (introduced in R2018b) will do what you want.
  댓글 수: 6
Gabriel Luca Pugliese Borges
Gabriel Luca Pugliese Borges 2022년 3월 21일
Alright, Strider. Thank you so much for all helping and advices. I will test all the options that you gave me.
Wish you a good day.
Star Strider
Star Strider 2022년 3월 21일
My pleasure!
You, too!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by