Creating a 2D matrix of non-zero modes from a 3D array

1 回表示 (過去 30 日間)
Daniel Reinowski
Daniel Reinowski 2019 年 11 月 26 日
コメント済み: Daniel Reinowski 2019 年 11 月 26 日
Hello,
I have a large 3D array Q (17019x68x50).
I'd like to create a new 2D matrix modeQ which is 68x50 (i.e. the latter two dimesions), with the values being the modes of each corresponding column in the array.
I'm interested only in non-zero modes, but other values are much less frequent than zero, so mode(Q,1) throws out a matrix of only zeroes.
I do not understand the nonzeros function enough to utilise it correctly either.
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 26 日
Yes the size of Q is 17019x68x50, what is resultant size as you expected?

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 11 月 26 日
Q(Q == 0) = NaN;
out = squeeze(mode(Q));
out(isnan(out)) = 0;
  1 件のコメント
Daniel Reinowski
Daniel Reinowski 2019 年 11 月 26 日
Thank you, that works exactly as desired.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by