How to find the maximum value for each 2 rows in an array?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
BN
le 3 Nov 2019
Modifié(e) : Thiago Henrique Gomes Lobato
le 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 commentaires
Réponse acceptée
Thiago Henrique Gomes Lobato
le 3 Nov 2019
Modifié(e) : Thiago Henrique Gomes Lobato
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!