Create a logistical variable based on time range

조회 수: 2 (최근 30일)
William Garrett
William Garrett 2020년 2월 22일
편집: dpb 2020년 2월 23일
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
Jacob Wood 2020년 2월 22일
Have you loaded the values into Matlab? Perhaps using xlsread() or tableread()?
William Garrett
William Garrett 2020년 2월 22일
I have loaded the table into Matlab yes - how would the tableread function enable me to sort the data by date and time sorry?

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

채택된 답변

dpb
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개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by