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!