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

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 comentarios

You mean OFF==0 and ON==~0, don't you?
Just create a logical variable that is T/F (or ON/OFF if make categorical) by
t.FilterON=(t.Filter_on_off~=0);
and use it for all kinds of uses like a grouping variable, etc., etc., ...
Thank you for your help, it has been useful for my data analysis.
How would I seperate out this data into a seperate array, so I can perform data analysis on the seperate sections? For example, I would like to find out the standard deviation seperately for when the filter is on or off.
Logical addressing (indexing)
sdON=std(t.DataVariable(t.FilterON));
sdOFF=std(t.DataVariable(~t.FilterON));
That's why I said it's useful for many things...
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 el 30 de Dic. de 2019
Editada: dpb el 30 de Dic. de 2019
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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Nov. de 2019

Editada:

dpb
el 30 de Dic. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by