Filtering a Single Column of One Table Based on Multiple Criteria from Another Table.
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
To start I am working on a different network and unable to show my code and will do my best to explain.
I have 2 tables (Table A starts at 130x19, Table B starts at 5000x8) that share a single variable header that contains ID numbers. I have successfully filtered down table A to 10x19. What I am having trouble doing currently is taking those 10 ID numbers to filter table B to show all rows (with all information) that have any of the unique 10 IDs.
0 Commenti
Risposte (1)
Star Strider
il 20 Feb 2025
5 Commenti
Siddharth Bhutiya
il 20 Feb 2025
If you only want the data from the data1 table then as Star Strider suggested above, using ismember + subscripting will also do the trick.
data1 = table(["A"; "B"; "C"; "D"; "E"; "A"; "C"], [1; 2; 3; 4; 5; 6; 7], 'VariableNames', {'Category', 'Value'});
data2 = table(["A"; "C"], 'VariableNames', {'Category'});
filteredData = data1(ismember(data1.Category, data2.Category),:)
Basically what the expression means is give me all the rows from data1 where data1's Category matches one of data2's Categories, which I believe is what you want.
Star Strider
il 20 Feb 2025
Vedere anche
Categorie
Scopri di più su Floating-Point to Fixed-Point Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!