# How to calculate average of data over a given time period?

8 visualizzazioni (ultimi 30 giorni)
benjamin giroud il 26 Mag 2020
Risposto: Eric Sofen il 9 Giu 2020
I have a large data file that contains thousands of records for each hour. The first six columns are date and time and the others are measured data. I need to make an average on an hourly basis (one hour, one row). I've tried datenum but it consumes a lot of time and process. Is there any faster solution instead of mine? without datenum??
This is my solution:
Average_data=[ ];
for i3=Start_time:0.041666666627862:Stop_time %one hour step%
Average_data=[Average_data; i3 mean(Raw_data((datenum(datetime(Raw_data(:,1:6)))<i3&...
datenum(datetime(Raw_data(:,1:6)))>i3-0.041666666627862&~isnan(Raw_data(:,6+input_column))),7:end))];
end
Benjamin
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Star Strider il 26 Mag 2020
Explor the many capabilities of the retime function.

Accedi per commentare.

### Risposte (1)

Eric Sofen il 9 Giu 2020
It would be helpful to see what your data looks like (are different time components) split into different table variables?) But as Star Strider recommended, consider using timetable and retime.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by