Remove spikes from a matrix.

5 visualizzazioni (ultimi 30 giorni)
Paulo Eduardo Beiral
Paulo Eduardo Beiral il 16 Ott 2019
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.

Risposta accettata

Daniel M
Daniel M il 16 Ott 2019
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 Commento
Paulo Eduardo Beiral
Paulo Eduardo Beiral il 16 Ott 2019
Modificato: Paulo Eduardo Beiral il 16 Ott 2019
Thank's Daniel, I just removed from matlab path the folder which "which nanmean" showed me, and now nanmean is working fine!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by