Selecting part of data that satisfies a criterion
6 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Cris LaPierre
on 17 Apr 2021
Edited: Cris LaPierre
on 17 Apr 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,:);
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!