Filter löschen
Filter löschen

Do calculations for certain hours in a 3D array

1 Ansicht (letzte 30 Tage)
Espen Mikkelsen
Espen Mikkelsen am 13 Mär. 2018
Beantwortet: Rik am 13 Mär. 2018
I have a 3D array with 30x50x8760. 30x50 is values from measurements. 8760 is measurements for every hour in one year. I also have a 8760x1 datetime array shown in, dd-MMM-yyyy HH:mm:ss. I want to do some calculations like f.eks the mean. There will be calculations for certain hours like 08:00:00, 09:00:00, 10:00:00 etc. How can I do this? The only way I know is to first make a 2D array from the 3D array, and make a table from the two arrays.

Akzeptierte Antwort

Rik
Rik am 13 Mär. 2018
You can use the hour function to get the submatrix with logical indexing.
temp=A(:,:,hour(date_vec)==8);
mean_val=sum(sum(temp,1),2)/(size(A,1)*size(A,2));

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by