Extracting specific data from time range excel
12 views (last 30 days)
Show older comments
I have exported data from a sensor reading. It doesn't allow me to extract hourly data and that's what I really need. In the excel table, I have the device name, date and time (10 mins interval), the readings. I would like to know a faster way to filter out 1 data reading per hour (data is provided every 10 mins interval).
0 Comments
Accepted Answer
Star Strider
on 4 Mar 2023
It would help to have the Excel file.
The ‘1 data raeading per hour’ request is open to intpretation.
Then, depending on what you want to do, you can either take a specific interval in every hour, or aggregate the data over every hour.
T1 = table(datetime(2023,03,01)+minutes(0:10:300).', randn(31,1), 'VariableNames',{'Timestamp','Sensor'})
EveryHour = T1(minute(T1{:,1})==0,:) % First Entry Every Hour
HourlyMean = table2timetable(T1);
HourlyMean = retime(HourlyMean, 'hourly','mean') % Mean Of Every Hour
A bit of clarification of what you want to do would help.
.
2 Comments
Star Strider
on 4 Mar 2023
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1314110/Data%20Sample.csv')
% TT1 = table2timetable(movevars(T1,4,'Before',1))
EveryHour = T1(minute(T1{:,4})==0,:)
No exact data exist for some time values, such as ‘00:00’ and ‘01:00’. They could be forced to exist using the approach in Interpolate Timetable Data to Time Vector, however that can create data where none previously existed, so I do not usuallly recommend it.
.
More Answers (0)
See Also
Categories
Find more on Spreadsheets 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!