How to find the maximum value for each 2 rows in an array?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Thiago Henrique Gomes Lobato
2019-11-3
编辑:Thiago Henrique Gomes Lobato
2019-11-3
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!