Create a logistical variable based on time range
1 次查看(过去 30 天)
显示 更早的评论
I have some air quality data from an office ranging from the 9th October to the 21st October.
I am trying to understand how air quality behaves when nobody is in the office. Therefore I need to seperate out the data from when nobody is in the office.
This is between 6:30pm and 6:30 am every day, apart from the 12th, 13th, 19th and 20th, when the office is empty all day (weekends).
I am assuming I can use a timerange to create a logistical variable which I can then use to index.
How do I create this logistical variable to seperate out these desired time ranges?
I have included some sample data, this is a subset because the excel file is very large in its totality
Two important things to note is that there a far more column variables in reality than I have attached and that in MATLAB the datetime variable changes from a xx/xx/xxxx xx:xx:xx to xx-xx-xxxx xx:xx:xx format
2 个评论
Jacob Wood
2020-2-22
Have you loaded the values into Matlab? Perhaps using xlsread() or tableread()?
采纳的回答
dpb
2020-2-22
编辑:dpb
2020-2-23
readtable is a convenient byway on the way to a timetable which will undoubtedly be your friend...
tt=readtable('Forum_aq_data.xlsx','ReadVariableNames',0); % read the .xlsx file, no header row
tt.Properties.VariableNames={'Time','AQ1','AQ2'}; % some at least partially meaningful names
tt=table2timetable(tt); % convert the table to a timetable
ixOffEmpty = isweekend(tt.Time) | ... % either weekend or
~isbetween(timeofday(ttforum.Time),duration("06:30:00"),duration("18:30:00")); % not between 6:30AM and 6:30 PM same day
ttEmpty=tt(ixOffEmpty,:); % save the portion wanted for analysis
Read up on how to process tables; there are many "tricks of the trade" that will ease statistics and those kinds of things immeasurably as well as grouping variables, etc., if some of the variables are things like locations, etc., Don't forget to turn those types of variables into categorical.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!