How do I find the maximum value of every 7 days
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Michiel Smit
el 10 de Jun. de 2020
Comentada: Michiel Smit
el 11 de Jun. de 2020
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
0 comentarios
Respuesta aceptada
KSSV
el 10 de Jun. de 2020
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
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!