Replace values in a matrix below 1% and above 99%

1 Ansicht (letzte 30 Tage)
FC93
FC93 am 8 Feb. 2017
Kommentiert: FC93 am 8 Feb. 2017
I have a big Matrix. In the Matrix I have a lot of values but also some NaN. Now £I want to replace all values that are below 1% percentil with the corresponding value of the 1% percentil. In a next step I want to replace all values above the 99% percentil with the value at the 99% percentil.
An example: If we take all numbers in the Matrix and the 1% percentil is 2, then I want to replace all values below 2 with 2.
Thank you for your help.

Akzeptierte Antwort

Adam
Adam am 8 Feb. 2017
Bearbeitet: Adam am 8 Feb. 2017
lowPercentileVal = prctile( myMatrix(:), 1 );
myMatrix( myMatrix < lowPercentileVal ) = lowPercentileVal;
highPercentileVal = prctile( myMatrix(:), 99 );
myMatrix( myMatrix > highPercentileVal ) = highPercentileVal;
  1 Kommentar
FC93
FC93 am 8 Feb. 2017
Thank you for your help. This is what I was looking for.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by