Tuesday, March 24, 2015

remove outliers in Matlab

Here's the code i wrote recently to remove the outliers from the experimental data. Anything outside the range from Q1-1.5IQR to Q3+1.5IQR will be removed.

a=[10 11 13 19 9 8 11 14 12 17 1 2 10 11 13 12 12 11 10];
IQR=iqr(a);
lowr=prctile(a,25)-1.5*IQR;
highr=prctile(a,75)+1.5*IQR;
new_a=a(a>lowr & a<highr);

No comments:

Post a Comment