フィルターのクリア

How do I find the maximum value of every 7 days

1 回表示 (過去 30 日間)
Michiel Smit
Michiel Smit 2020 年 6 月 10 日
コメント済み: Michiel Smit 2020 年 6 月 11 日
Hello!
I have a matrix consisting of daily maxima water levels. For a project, i need to find the weekly maxima. To do so, I want to find the maximum values of every 7 rows. For example:
[year month day Waterlevel]
2000 1 1 94
2000 1 2 95
2000 1 3 98
2000 1 4 101
2000 1 5 103
2000 1 6 104
2000 1 7 105
2000 1 8 106
2000 1 9 106
2000 1 10 104
2000 1 11 102
2000 1 12 102
2000 1 13 101
2000 1 14 99
These are the first 14 rows of my matrix. So i want to find the maximum value of rows 1:7 and then 8:14, 15:21 and so on. Also, I wish to keep the days

採用された回答

KSSV
KSSV 2020 年 6 月 10 日
d = (1:36)' ; % let this be number of days
z = rand(size(d)) ; % let this be your water level
% make d divisble by 7 for reshaping
n = length(d) + (7 - rem(length(d),7)) ;
n = n-length(d) ;
d = [d ; NaN(n,1)] ; % append NaN's if extra values are needed
z = [z ; NaN(n,1)] ; % append NaN's if extra values are needed
% reshape to 7 rows
d = reshape(d,7,[]) ;
z = reshape(z,7,[]) ;
iwant = max(z) ; % get maximum for each 7 days
  1 件のコメント
Michiel Smit
Michiel Smit 2020 年 6 月 11 日
Thanks very much!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by