MATLAB: Removing highest and lowest 5% of data as outliers using prctile

MATLABoutlierspercentagepercentileprctile

I have some numerical data imported from an Excel sheet in a column. I want to remove the highest 5% and the lowest 5% of these numbers as outliers using the prctile function. How can I do this?
Thanks in advance!

Best Answer

% Data values are in X; X2 holds remaining values after outliers removed
Y = prctile(X,[5,95]);
X2 = X(X>Y(1) & X<Y(2)); % maybe you want >= and <=, depending on your definition of outlier
Related Question