Matrix addition hour values to day values
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marek Dworak
am 4 Jan. 2021
Bearbeitet: Cris LaPierre
am 4 Jan. 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 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 4 Jan. 2021
Bearbeitet: Cris LaPierre
am 4 Jan. 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')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!