필터 지우기
필터 지우기

I need help on finding the max & min values of a 3d array.

조회 수: 50 (최근 30일)
Petronella
Petronella 2022년 2월 8일
편집: John D'Errico 2022년 2월 8일
I need help on finding the max & min values of a 3d array.

채택된 답변

Turlough Hughes
Turlough Hughes 2022년 2월 8일
From the documentation for max:
M = max(A,[],'all')
finds the maximum over all elements of A. This syntax is valid for MATLAB® versions R2018b and later.
From the documentation for min
M = min(A,[],'all')
finds the minimum over all elements of A. This syntax is valid for MATLAB® versions R2018b and later.

추가 답변 (1개)

John D'Errico
John D'Errico 2022년 2월 8일
편집: John D'Errico 2022년 2월 8일
min and max are not sufficient? For example:
A = randi(1000,[4 3 2])
A =
A(:,:,1) = 190 179 810 90 414 728 714 631 716 310 324 780 A(:,:,2) = 778 790 612 245 897 12 217 24 776 586 954 442
[maxval,maxind] = max(A,[],'all')
maxval = 954
maxind = 20
So 954 is the largest value. It occurs where? At the 20th element of A. That is, if the elements of A were strung out in a single vector as they are stored in memory. What subscripts does that correspond to?
[irow,icol,ipage] = ind2sub(size(A),maxind)
irow = 4
icol = 2
ipage = 2
4th row. 2nd column, 2nd page.
Min works the same way. Ok, it finds the min, not the max, so not exactly the same way. :)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by