Index table with cell array
Mostra commenti meno recenti
I have a table in which one of the columns is a cell array of text data, and a cell array C that contains a subset of this text. Is there a way to extract from the table only the rows with the text in C?
Risposta accettata
Più risposte (1)
Matt J
il 19 Nov 2021
0 voti
Yes, you can use ismember(...,'rows') to find the indices of the rows.
3 Commenti
Kim Maria Damiani
il 19 Nov 2021
@Kim Maria Damiani: do not use the whole table, just the variable that you want to compare. Also the order needs to be swapped around in order for it to work correctly:
idx = ismember(T.NameOfVariable, C)
out = T(idx,:)
Kim Maria Damiani
il 19 Nov 2021
Categorie
Scopri di più su Data Type Identification in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!