# Multiple Maximas in multiple matrices

1 view (last 30 days)
Eren Atar on 14 Jun 2022
Commented: Voss on 14 Jun 2022
Hello,
I want to get multiple maximas of multiple matrices.
I got a solution to get the maxValue but it gives me one absolute max Value.
I want a output like this for this example:
max Value = [15 25 35]
% data
matrix1=[10:1:15];
matrix2=[15:1:25];
matrix3=[25:1:35];
%max
maxValue = max([matrix1(:);matrix2(:);matrix3(:)])
maxValue = 35
Jan on 14 Jun 2022
Hint: [] is the operator for a concatenation of arrays. 10:1:15 is a vector and [10:1:15] concatenates it with nothing. So this is a waste of time only.

Voss on 14 Jun 2022
% data
matrix1=[10:1:15];
matrix2=[15:1:25];
matrix3=[25:1:35];
%max
maxValue = cellfun(@max,{matrix1 matrix2 matrix3})
maxValue = 1×3
15 25 35
Voss on 14 Jun 2022
@Eren Atar You're welcome!

Image Analyst on 14 Jun 2022
Try it this way, with max() inside the brackets:
% data
matrix1=[10:1:15];
matrix2=[15:1:25];
matrix3=[25:1:35];
%max
maxValue = [max(matrix1(:)); max(matrix2(:)); max(matrix3(:))]
maxValue = 3×1
15 25 35

### Categories

Find more on Matrices and Arrays in Help Center and File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by