Selecting part of data that satisfies a criterion

6 visualizaciones (últimos 30 días)
Stormero
Stormero el 17 de Abr. de 2021
Editada: Cris LaPierre el 17 de Abr. de 2021
Hi All,
How do I select rows of a multivariate table if the row falls within a range of interest? For example, my data has 10 columns and 100 rows and I want to select only rows that fall within the the IQR of the values in Column B. I have written the following code to select the rows of Column B that fall within its IQR but I don't know how to generalise it to all colums:
v = (Data.ColumnB);
q = quantile(v,[0.25 0.75]);
Y = v(v>=q(1) & v<=q(2));
D25_75 = table(Y,'VariableNames',{'ColumnB'});
Your help is highly appreciated.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 17 de Abr. de 2021
Editada: Cris LaPierre el 17 de Abr. de 2021
You seem to be taking the correct approach. Perhaps the most helpful thing to point out is this page on how to access data in a table.
I would create a logical array (see Ch 12 of MATLAB Onramp) using the iqr criteria on column b, then use that to select the rows to keep (or remove).
We don't have your data, but I think your code might look something like this.
q = quantile(Data.ColumnB,[0.25 0.75]);
ind = Data.ColumnB >= q(1) & Data.ColumnB <= q(2));
D25_75 = Data(ind,:);

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by