Remove spikes from a matrix.

조회 수: 5 (최근 30일)
Paulo Eduardo Beiral
Paulo Eduardo Beiral 2019년 10월 16일
편집: Paulo Eduardo Beiral 2019년 10월 16일
Hey all!
I've got a huge matrix of 3587 x 5677056, and I've got to find the average (avg) of this matrix and the standart deviation (sd) for removing the spike values that are along the matrix. So, I will remove all the values of my matrix that are greater than (avg + 3 sd). I've build up the following code:
media_total = NaNmean(matriz_total, 'all');
x = (avg + 3sd)
L = bsxfun(@le,media_total,x);
media_total(L) = NaN;
But I'm getting the following error:
Error using size
Dimension argument must be a positive integer scalar within indexing range.
Error in nanmean (line 43)
count = size(x,dim) - sum(nans,dim);
Does anyone know how to solve it?
And aftewards, how can I effectively remove all the values greater than (avg + 3 sd) and substitute these values for NaN?
Thank's very much for any help!!!
Regards, Paulo Beiral.

채택된 답변

Daniel M
Daniel M 2019년 10월 16일
My version of nanmean only goes up to line 22 in R2019a, so I'm not sure what you have. Perhaps someone has written an overloaded version of that function. What happens when you type this into the command window:
which nanmean
Regardless, this is fairly simple. Other than the fact that a matrix that size of type double would be 162 GB.
xm = nanmean(x,'all');
xs = nanstd(x,0,'all');
x(x > xm+3*xs) = NaN;
  댓글 수: 1
Paulo Eduardo Beiral
Paulo Eduardo Beiral 2019년 10월 16일
편집: Paulo Eduardo Beiral 2019년 10월 16일
Thank's Daniel, I just removed from matlab path the folder which "which nanmean" showed me, and now nanmean is working fine!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by