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

조회 수: 2 (최근 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;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by