How can I extract table rows based on the value of a single column

1 次查看(过去 30 天)
I am trying to extract data from a table. My table includes air quality data from a number of sensors and I want to compare the results for when a filter was on or off.
The table headings and a line of sample data is shown below.
'Date_Time' , 'PM2.5', 'UV_BC', 'Blue_BC', 'Green_BC', 'Red_BC', 'IR_BC', 'Particle_Count' , 'Particle_Conc', 'Filter_on_off'
09-10-2019 10:50:00 3 538 398.300 364.9 375.5 935.6 155.4708 51.9907 0
The 'Filter_on_off' value ranges from 0 to 1 but is not a logistical value, values of 0.5 and 0.75 are possible (related to fan speed)
How would I isolate data when the filter is off ('Filter_on_off' = 0) and on ('Filter_on_off' >1) for comparison?
  5 个评论
William Garrett
William Garrett 2019-12-30
Thank you for your help.
I now have the issue that I want to sort the data into the different fan speeds. E.g. I need to know the max particle conc for fan speeds, 0, 0.5, 0.75 and 1. The above approach does not work as it sorts the data into logistical arrays dependant on wether the fan speed is 1 or <1. How would I group stats into these 4 different categories? Whenever i use the group stats function I am informed I need to use a logistical variable
Any help would be much appreciated
dpb
dpb 2019-12-30
编辑:dpb 2019-12-30
Create a variable with the desired categories and populate it by sorting into proper category each value. A histogram would be easy way of assigning bin numbers if the speeds can be anything between 0-1.
OTOH, if they are a finite number of set speeds like those above, then simply categorical(fanspeed) will do it for the categories in unique(fanspeed)(*) You can then either use those values as the category names or assign others like 'OFF', 'SLOW','MEDIUM','HIGH' or whatever you wish.
Again, I can't urge you enough to read the documentation on categorical arrays and look at examples. varfun and/or splitapply are your friends for all these kinds of things...they all just drop in your lap if you set it up to use the facilities TMW provides.
(*) If there aren't all possible categories in the dataset, use the optional inputs to the function to define them.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by