Detect Outlier with for Schleife

5 visualizaciones (últimos 30 días)
cemsi888
cemsi888 el 16 de Sept. de 2015
Comentada: cemsi888 el 16 de Sept. de 2015
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

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Sept. de 2015
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 comentarios
Image Analyst
Image Analyst el 16 de Sept. de 2015
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 el 16 de Sept. de 2015
sorry ıt ıs really simple ı have fiber .Maybe ı have to make break :(

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Testing Frameworks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by