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

1 次查看（过去 30 天）
FC93 2017-2-8

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.

### 采纳的回答

lowPercentileVal = prctile( myMatrix(:), 1 );
myMatrix( myMatrix < lowPercentileVal ) = lowPercentileVal;
highPercentileVal = prctile( myMatrix(:), 99 );
myMatrix( myMatrix > highPercentileVal ) = highPercentileVal;
##### 1 个评论显示 -1更早的评论隐藏 -1更早的评论
FC93 2017-2-8
Thank you for your help. This is what I was looking for.

### 类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

### Community Treasure Hunt

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

Start Hunting!

Translated by