tresholding by summing over a dimension of a matrix

2 visualizaciones (últimos 30 días)
Lucrezia Cester
Lucrezia Cester el 25 de Nov. de 2019
Respondida: Andrei Bobrov el 27 de Nov. de 2019
Hello,
I am trying to treshold data by summing over elemtns in the third dimension of a matrix and if the sum of all elements in a row of the third dimension is larger than a treshold value, all that row is set to NaN. However, I think the code I wrote must not be doing what I think it is since it is taking a very long time to compile.
Could you help me write some code please?
for c = 1:200000
for b = 1:32
for a= 1:32
if sum(micron_62frames(a,b,:),3) > 200000*65
micron_62frames(a,b,:) = NaN;
elseif sum(micron_62frames(a,b,:),3) < 200000*65
micron_62frames(a,b,:) = micron_62frames(a,b,:);
end
end
end
end
  2 comentarios
Lucrezia Cester
Lucrezia Cester el 25 de Nov. de 2019
Hey I fixed it, outer loop was unnecessary
David Goodmanson
David Goodmanson el 25 de Nov. de 2019
Also the elseif statement and the command that goes with it is unneccesary, since all you are doing with
micron_62frames(a,b,:) = micron_62frames(a,b,:)
is setting a bunch of stuff equal to what it is already.

Iniciar sesión para comentar.

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 27 de Nov. de 2019
k = size(micron_62frames,3);
lo = sum(micron_62frames,3) > 13e6;
micron_62frames(repmat(lo,1,1,k)) = nan;

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by