You can easily calculate the desired percentile in MATLAB using the quantile
function. The 99th percentile can be calculated as follows:
Suppose you have a vector data
of numeric values; you can calculate the 99th percentile as follows:
main.m114 chars3 lines
Here, p
is the desired percentile and data
is a vector of numeric values. The quantile
function returns the p-th percentile of data
.
Alternatively, you can use the prctile
function to achieve the same result:
main.m67 chars2 lines
Either way, pct
will be the value that represents the 99th percentile of the data.
Note that if you have NaN values in data
, the percentile functions will return NaN as the output. You can remove these NaN values using the isnan
function and data(~isnan(data))
.
gistlibby LogSnag