Create a logistical variable based on time range

2 visualizaciones (últimos 30 días)
William Garrett
William Garrett el 22 de Feb. de 2020
Editada: dpb el 23 de Feb. de 2020
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 comentarios
Jacob Wood
Jacob Wood el 22 de Feb. de 2020
Have you loaded the values into Matlab? Perhaps using xlsread() or tableread()?
William Garrett
William Garrett el 22 de Feb. de 2020
I have loaded the table into Matlab yes - how would the tableread function enable me to sort the data by date and time sorry?

Iniciar sesión para comentar.

Respuesta aceptada

dpb
dpb el 22 de Feb. de 2020
Editada: dpb el 23 de Feb. de 2020
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.

Más respuestas (0)

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by