Calculate minutes average values
8 views (last 30 days)
Show older comments
Hi, everyone.
As attached is my observations data for 24 hours from different transmitter (PRN) . The data here are from 1/1/2014 to 31/1/2014 resulting in thousands of row. From this excel (refer attachment), I need to extract 1-minute and 5-min averages for VTEC, S4 and Sigma for each 31 days.
Therefore, later I can do plotting for the graph but currently stuck here finding shortcut to find averages with thousands of data. Does anyone have any ideas? Thank you in advanced.
From Excel:
Column A - Day Column B- Time Column C- GPS TOW (may ignore)
Column D- PRN
Column E- VTEC Column F- S4 Column G- Sigma
0 Comments
Accepted Answer
Cris LaPierre
on 5 Jan 2021
I would import the spreadsheet as a table, then convert the day and time into a datetime, convert that to a timetable, and use the retime function to combine the data into 1 minute and 5 minute increments.
data = readtable("Book_Jan.xlsx");
% Convert DAY and TIME into durations
data.DAY = days(data.DAY);
data.TIME = days(data.TIME);
% Create a datetime
data.TimeStamp = datetime(2014,01,01) + data.DAY-1 + data.TIME;
data.TimeStamp.Format = "MM-dd-yy HH:mm";
% Convert the table to a timetable
dataTT = table2timetable(data,"RowTimes","TimeStamp");
% Use retime to average the data into 1 and 5 minute increments.
dataTT1min = retime(dataTT(:,["VTEC" "S4" "Sigma"]),"minutely","mean")
dataTT5min = retime(dataTT(:,["VTEC" "S4" "Sigma"]),"regular","mean","TimeStep",minutes(5))
More Answers (0)
See Also
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!