Averaging second data to minute data
显示 更早的评论
Hello,
I have a file with 2 columns. First column is Date, second column is temperature. I would like to average the seconds data to minute data. Can someone please help? I would then like to convert the minute data to hourly data by taking into account only the 10 minutes interval of each hour. For example at 1pm, taking into account only the minute data from 12:55 to 1:05 Can someone please help?
I managed to read the csv file so now I have an array with 2 columns of date and second data. I would really appreciate it if someone helps.
回答(1 个)
dpb
2018-10-10
Convert to timetable and use retime
tt_secs=array2timetable(data(:,2),'rowtimes',datetime(data(:,1))); % convert to timetable
tt_mins=retime(tt_secs,'minutely');
Going to hourly then shouldn't be too much of a stretch to guess! :)
You may have to provide the input format for the date data to datetime; you don't say how it's constructed.
5 个评论
Ayman Fathy
2018-10-10
dpb
2018-10-10
Upgrade? Much useful since then has been introduced.
Are your data sets complete; that is no missing observations?
Ayman Fathy
2018-10-10
Ayman Fathy
2018-10-10
dpb
2018-10-10
The missing values are a pain...that's why I suggested retime; it takes care of that for you.
Two basic choices, then.
- Interpolate and introduce NaN for missing seconds so can use the fixed number of seconds/minute to reshape() and average with nanmean to ignore the missing values, or
- Find elements in each minute by binning with histc and averaging the elements of each bin.
类别
在 帮助中心 和 File Exchange 中查找有关 Timetables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!