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 个)

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 个评论

It seems like I don't have the functions datatime, retime and array2timetable since I am using matlab 2012. Is there a way around it? Thanks
Upgrade? Much useful since then has been introduced.
Are your data sets complete; that is no missing observations?
I have 3 months of second data with some missing data in between so I believe I can't just take the average of every 60 rows. There has to be a method using the serial date numbers in the first column and use it to average the temperature data in the second column.
Please correct me if I am wrong. Thanks.
The missing values are a pain...that's why I suggested retime; it takes care of that for you.
Two basic choices, then.
  1. 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
  2. Find elements in each minute by binning with histc and averaging the elements of each bin.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Timetables 的更多信息

评论:

dpb
2018-10-10

Community Treasure Hunt

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

Start Hunting!

Translated by