Convert 1 min average data to hourly average data

조회 수: 3 (최근 30일)
Mehran Mustafa
Mehran Mustafa 2017년 2월 28일
댓글: Kanachi 2017년 11월 30일
Hello!
I have data in the following format:
mm-dd-yy HH:MM m/s
There are some missing entries in this data, and I need to convert this to hourly average data. I have data for a whole year and doing it manually or just with for and if statements will be extremely time consuming. Could anyone please help me with this to get it done in the most efficient way?

답변 (3개)

Walter Roberson
Walter Roberson 2017년 2월 28일
If you have a new enough MATLAB, you can read the data using readtable() and convert the resulting table() object to a timetable() object which then has direct functions to group by time.
Otherwise, the easiest way to read the date and time depends on which MATLAB release you have. Also, is the file a .xls or .xlsx or a .csv ?
  댓글 수: 4
Mehran Mustafa
Mehran Mustafa 2017년 3월 1일
편집: Mehran Mustafa 2017년 3월 1일
It did not work with 'basic' option. It said worksheet 'basic' not found. So i tried without 'basic' and got the following output for num(1:2,:) raw(1:2,:):
Also, now I have MATLAB 2016a as well. I have the function readtable() but not timetable().
Walter Roberson
Walter Roberson 2017년 7월 17일
I should have suggested
[num, raw] = xlsread('YourFile.xlsx', [], [], 'basic');
compared to the same thing without the 'basic' option, for R2013a.

댓글을 달려면 로그인하십시오.


Chad Greene
Chad Greene 2017년 3월 1일
If you can get time into datenum format, downsample_ts makes it easy.
  댓글 수: 1
Kanachi
Kanachi 2017년 11월 30일
Hi,
I have the timestamp of my timeseries data for hydrophone data in datenum format. Each record is 8min duration. I would like to do 3hourly averages for my data and look at the plots. How do i got about. I have obtained the power spectrum levels using pwelch and got the corresponding frequecies too. Please advise. THANK YOU.

댓글을 달려면 로그인하십시오.


Ohad Zivan
Ohad Zivan 2017년 7월 17일
if you have a timetable (called OldData here) in matlab it should be easy enough.
NewData=retime(OldData ,'hourly','mean');
you can also define your own time steps (for example, 15 minute averages):
TimeStep=[OldData.Date(1):minutes(15):OldData.Date(end)];
NewData2=retime(OldData ,TimeStep,'mean');
to make a timetable, use MathWorks help.

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by