필터 지우기
필터 지우기

Detect Outlier with for Schleife

조회 수: 1 (최근 30일)
cemsi888
cemsi888 2015년 9월 16일
댓글: cemsi888 2015년 9월 16일
I want to detect Outliers in my Measurement datas and thats why i use Grubbs Outlier Test. I wrote code but i got this error. Could you please help me to solve this problem? Error :Attempted to access a(18); index out of bounds because numel(a)=17.
Error in ausreisser (line 9) PG=abs((a(ii)-mu))/s
clear all
clc
a=[ 1 2 3 4 5 6 7 8 9 10 1100000000000 11 12 90 100 112 1000 1000000000];
mu=mean(a)
s=std(a)
for ii=1:length(a)
PG=abs((a(ii)-mu))/s
VG=3.2095;
else
if VG>PG
disp('kein Ausreisser vor')
disp('Es liegt ein Ausreisser vor')
a(ii)=[];
ii=ii+1
end
end
  댓글 수: 1
cemsi888
cemsi888 2015년 9월 16일
Could you please help me?

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

채택된 답변

Image Analyst
Image Analyst 2015년 9월 16일
Try this vectorized approach:
a=[ 1 2 3 4 5 6 7 8 9 10 1100000000000 11 12 90 100 112 1000 1000000000];
mu=mean(a)
s=std(a)
PG=abs(a-mu)/s
VG=3.2095;
outliers = VG > PG
a(outliers) = []
  댓글 수: 3
Image Analyst
Image Analyst 2015년 9월 16일
Sorry, I just took VG>PG from your original code without thinking much about it. Just reverse the sign to get outliers:
a=[ 1 2 3 4 5 6 7 8 9 10 1100000000000 11 12 90 100 112 1000 1000000000];
mu=mean(a)
s=std(a)
PG=abs(a-mu)/s
VG=3.2095;
outliers = VG < PG
a(outliers) = []
cemsi888
cemsi888 2015년 9월 16일
sorry ıt ıs really simple ı have fiber .Maybe ı have to make break :(

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Testing Frameworks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by