tresholding by summing over a dimension of a matrix
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
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.
Respuestas (1)
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;
0 comentarios
Ver también
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!