How to find the max of each “slice” in a multidime

2019-02-24 12:54发布

问题:

I have an n-dimensional matrix Q. I can find the max values through the last dimension by:

m = max(Q,[],n).

However, I do not know how to find the max values through the last "slice". I need something "like"

m = max(Q,[],n-1,n).

For example, if I have

A(:,:,1) = [1 2 3 ; 4 50 6]
A(:,:,2) = [9 8 7 ; 10 12 1]

I would like to have m = [9 50].

Can you help me with this?

回答1:

You need a double call to max:

m = max(max(A, [], 3), [], 2)