3D matrix, max in z direction

조회 수: 63 (최근 30일)
lunalara
lunalara 2016년 8월 7일
댓글: Rik 2021년 2월 17일
Hello all ,
I am working with data arranged in a large 3D matrix and am wondering how I might find the maximum value in the Z direction of all elements at a specific x,y coordinate.
For example, if:
A = [1 2 3; 4 7 8]
B = [6 4 2; 3 5 7]
C = [3 3 9; 2 3 2]
and i arrange the matrix as such:
data_3d = cat(3, A, B, C)
I would like to find the maximum value of all 'z' elements positioned at the x,y coordinates(1,1) compared to each other, where: max_1 = 6
Is there a simple function to do this, or is it necessary to call each individual element in the following manner:
max_1 = max([A(1,1) B(1,1) C(1,1)])
(will this ^ even work?)
A bit of a matlab newbie, and any help is greatly appreciated. :) Thank you for your time

채택된 답변

Star Strider
Star Strider 2016년 8월 7일
Try this:
max_data_3d = max(data_3d, [], 3)
max_data_3d =
6 4 9
4 7 8
  댓글 수: 4
lunalara
lunalara 2016년 8월 8일
Star, you have made my day.
It would probably be much easier to get the full maximum beforehand, then just pick and choose which values are important from the resulting matrix like you said.
Thank you so much for your help!!
Star Strider
Star Strider 2016년 8월 8일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Fathia Mohammed
Fathia Mohammed 2021년 2월 17일
max(A,[],3)
  댓글 수: 1
Rik
Rik 2021년 2월 17일
How is this different from what Star Strider posted?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by