tresholding by summing over a dimension of a matrix

1 回表示 (過去 30 日間)
Lucrezia Cester
Lucrezia Cester 2019 年 11 月 25 日
回答済み: Andrei Bobrov 2019 年 11 月 27 日
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 件のコメント
Lucrezia Cester
Lucrezia Cester 2019 年 11 月 25 日
Hey I fixed it, outer loop was unnecessary
David Goodmanson
David Goodmanson 2019 年 11 月 25 日
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.

サインインしてコメントする。

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2019 年 11 月 27 日
k = size(micron_62frames,3);
lo = sum(micron_62frames,3) > 13e6;
micron_62frames(repmat(lo,1,1,k)) = nan;

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by