How to find the maximum value for each 2 rows in an array?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
BN
am 3 Nov. 2019
Bearbeitet: Thiago Henrique Gomes Lobato
am 3 Nov. 2019
Hello everyone,
I have a 3d array, precip= :,:, 720. in fact 720 is a column. I want to find the maximum value in this column two-by-two in rows. And saving the bigger value and eliminate the smaller one. and do it for all 720-row two-by-two
for example:
1) 54
1) 34
2) 97
2) 21
3) 3
3) 0
to
1) 54 ( 54>34)
2) 97
3) 3
so if the dimension before doing this is precip = :, :, 730, after this work should be precip = :, :, 365.
I wanna practical this for a 3d array which the third dimension is what I talking about.
I'm attaching all my array.
Thank you
0 Kommentare
Akzeptierte Antwort
Thiago Henrique Gomes Lobato
am 3 Nov. 2019
Bearbeitet: Thiago Henrique Gomes Lobato
am 3 Nov. 2019
If I understood right you want the maximum element-wise matrix entry between the two matrices that appear in your 3rd dimension in consecutive index, right? If it is this I belive this is the fastest way to do it in Matlab
A = load('my_array.mat');
A = A.the_array;
% Create Array to store the data
NewArray = max(A(:,:,1:2:end),A(:,:,2:2:end)); % Save maximum element-wise element for each matrix between 2 by 2 indexes
size(NewArray)
ans =
25 21 365
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!