Check for column in table

How do I search whether a column, lets say 'Column1', exists in a table, Table_1, without using strmatch as it is not recommended.

Réponses (2)

Kevin Phung
Kevin Phung le 10 Juil 2019
Modifié(e) : Kevin Phung le 10 Juil 2019

0 votes

any(ismember(Table_1.Properties.VariableNames,'Column1'))
strcmp works too, in place of ismember
Shubham Sangle
Shubham Sangle le 10 Juil 2019

0 votes

Exist_Column = strcmp('My_Column',My_Table.Properties.VariableNames)
val = Exist_Column(Exist_Column==1) ;

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by