17 views (last 30 days)

Hello,

I have a 3d array, precip= :,:, 8760. in fact 8760 rows are available in one column. I want to find the maximum value in this column 24-by-24 in rows. And saving the bigger value and eliminate the smaller one. and do it for all 8760-row

so if the dimension before doing this is precip = :, :, 8760, 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. as the volume of original file is so big I cut first 72 rows and attach it

Thank you

Shubham Gupta
on 14 Nov 2019

Edited: Shubham Gupta
on 14 Nov 2019

According to the comments, you have provided, this will produce the desired output :

yd = max(max(mn2t)); % first find maximum for each hour

y = reshape(yd,24,1,size(yd,3)/24); % reshape it by day

output = max(y); % find maximum of each day

Let me know if this works !

Shubham Gupta
on 14 Nov 2019

Simply use for loop mn2t:

output = cell(size(mn2t));

for i = 1:length(mn2t)

mn2t_mat = mn2t{i}; % extract matrix of ith element

yd = max(max(mn2t_mat)); % first find maximum for each hour

y = reshape(yd,24,1,size(yd,3)/24); % reshape it by day

output{i} = max(y); % find maximum of each day

end

Output will be cell vector with each cell containing maximum of each cell of mn2t.

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 7 Comments

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_763252

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_763252

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_763253

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_763253

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_763258

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_763258

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_763605

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_763605

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_767079

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_767079

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_767082

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_767082

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_767083

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/489065-how-to-find-the-maximum-value-for-each-24-rows-in-an-array#comment_767083

Sign in to comment.