1

Let say if have a 3D matrix A=randi([1, 9],[2 2 9]), how do I find the maximum value from all the slices and return only one maximum value? Thanks!

Gregor Isack
  • 1,111
  • 12
  • 25

1 Answers1

2

use MATLAB's max function as follows:

max(A(:))

Example:

A=randi([1, 9],[2 2 2])

A(:,:,1) =

 5     1
 9     4

A(:,:,2) =

 1     8
 8     8

max(A(:))

ans =
 9
ibezito
  • 5,782
  • 2
  • 22
  • 46