Essacete
Essacete

Reputation: 3

Element-by-element max values in multidimensional matrix

I have a few multidimensional matrices of dimensions mxnxt, where each element in mxn is an individual sensor input, and t is time. What I want to do is analyse only the peak values for each element in mxn over t, so I would end up with a single 2D matrix of mxn containing only max values.

I know there are are ways to get a single overall max value, but is there a way to combine this with element-by-element operations like bsxfun so that it examines each individual element over t?

I'd be grateful for any help you can give because I'm really stuck at the moment. Thanks in advance!

Upvotes: 0

Views: 54

Answers (2)

dlavila
dlavila

Reputation: 1212

You can call max() with the matrix and select the dimension (look the documentation) on which the operation will be calculated, e.g

M = max(A,[],3)

Upvotes: 1

Santhan Salai
Santhan Salai

Reputation: 3898

Is this what you want?

out = max(A,[],3);        %// checking maximum values in 3rd dimension

Example:

A = randi(50,3,3,3);      %// Random 3x3x3 dim matrix
out = max(A,[],3);

Results:

A(:,:,1) =

35     5     8
38    12    42
23    46    27


A(:,:,2) =

50     6    39
 4    49    41
23     1    44


A(:,:,3) =

 5    41    10
20    22    14
13    46     8

>> out

out =

50    41    39
38    49    42
23    46    44

Upvotes: 1

Related Questions