prctile
Percentiles of a sample.
Category: Data Import and Analysis > Descriptive Statistics
Syntax
Y = prctile(X, p)
Percentiles p (from 0 to 100) of the vector X, or of each column of a matrix.
Y = prctile(X, p, dim)
Along dimension dim.
Description
The p-th percentile is the value below which about p percent of the data fall. The 50th is the median and the 25th and 75th are the quartiles. Between data points the function interpolates linearly, using the convention that the sorted values sit at the midpoints of equal probability bins; values of p beyond the first and last of these return the minimum and maximum.
prctile(X, p) equals quantile(X, p/100).
Input arguments
X- Numeric vector or matrix.
p- Percentages between 0 and 100, scalar or vector.
Output arguments
Y- The requested percentiles.
Example
Quartiles
x = [3 1 4 1 5 9 2 6 5 3];
prctile(x, [25 50 75])
Output
ans = 1×3
2.0000 3.5000 5.0000