Matrix addition hour values to day values
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marek Dworak
el 4 de En. de 2021
Editada: Cris LaPierre
el 4 de En. de 2021
Hello guys it is my first question in here so you can imagine I'm not that good at matlab.
I got a table with 8760 lines (beta). Every value is an hour value and I wanted to sum every 24 lines to one day if you know what i mean.
So i need a loop or a possibility without "sum" command which can count 24 lines together and go to the next 24.
The results have to be a new matrix with 365 lines (so one year).
My code doesnt work but maybe you can help.
Its my first semester informatics and I've been trying to solve it for days.
n = 1;
N = 24;
for i = b:c;
for v = 1:8760
Beta(1,v) = beta(n,N);
n = n + 24
N = N + 24
end
end
0 comentarios
Respuesta aceptada
Cris LaPierre
el 4 de En. de 2021
Editada: Cris LaPierre
el 4 de En. de 2021
If I were going to do this, I would create a vector of datetimes incremented by 1 hour. I would then create a table with the datetimes and beta. I would then use groupsummary to calculate the sum of each day.
Here's a rough example.
beta = rand(8760,1);
d = datetime(2020,1,1,0,0,0)+hours(0:length(beta)-1)';
data = table(d,beta)
dailySum = groupsummary(data,'d','dayofyear','sum')
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!