y = iqr(X)
y = iqr(X) returns the interquartile range of the values in X. For vector input, y is the difference between the 75th and the 25th percentiles of the sample in X. For matrix input, y is a row vector containing the interquartile range of each column of X. For N-dimensional arrays, iqr operates along the first nonsingleton dimension of X.
iqr(X,dim) calculates the interquartile range along the dimension dim of X.
x = normrnd(0,1,100,100); s = std(x); s_IQR = 0.7413*iqr(x); efficiency = (norm(s-1)./norm(s_IQR-1)).^2 efficiency = 0.3297
The IQR is a robust estimate of the spread of the data, since changes in the upper and lower 25% of the data do not affect it. If there are outliers in the data, then the IQR is more representative than the standard deviation as an estimate of the spread of the body of the data. The IQR is less efficient than the standard deviation as an estimate of the spread when the data is all from the normal distribution.
Multiply the IQR by 0.7413 to estimate σ (the second parameter of the normal distribution.)