Matrix addition hour values to day values
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Marek Dworak
il 4 Gen 2021
Modificato: Cris LaPierre
il 4 Gen 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 Commenti
Risposta accettata
Cris LaPierre
il 4 Gen 2021
Modificato: Cris LaPierre
il 4 Gen 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')
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!