MATLAB Answers

How to find the maximum value for each 24 rows in an array?

10 ビュー (過去 30 日間)
BN2
BN2 2019 年 11 月 4 日
回答済み: BN2 2019 年 11 月 14 日
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
  7 件のコメント
BN2
BN2 2019 年 11 月 13 日
ok if assume that on this earth 1 day is of 2hr, then the output is:
Day = 1
T = 90
Day = 2
T = 900
I don't want to change the first and second dimensions.
input = :, :, 87600
output = :, :, 365 or 366

サインインしてコメントする。

採用された回答

Shubham Gupta
Shubham Gupta 2019 年 11 月 14 日
編集済み: Shubham Gupta 2019 年 11 月 14 日
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 !
  2 件のコメント
Shubham Gupta
Shubham Gupta 2019 年 11 月 14 日
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.

サインインしてコメントする。

その他の回答 (1 件)

Community Treasure Hunt

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

Start Hunting!

Translated by