MATLAB: 90% Percentile of Matrix

90th percentile

Hi! I am trying to find a way to calculate the 90% percentile of a matrix (1,n) . I provide an example below, and the value I would need to find is 0.292. (Note the matrix will changes in length). How could this be done?
[0.289, 0.254, 0.287, 0.292, 0.289, 0.267, 0.289, 0.304, 0.284, 0.282]

Best Answer

Here are two possibilities, the second of which gives you the exact value in your Question:
v = [0.289, 0.254, 0.287, 0.292, 0.289, 0.267, 0.289, 0.304, 0.284, 0.282];
Out1 = prctile(v, 90)
Out2 = interp1(linspace(1/numel(v),1,numel(v)), sort(v), 0.9)
producing:
Out1 =
0.2980
Out2 =
0.2920
.