MATLAB Answers

0

Check for column in table

Asked by Rohith Sudheer on 10 Jul 2019
Latest activity Answered by Shubham Sangle on 10 Jul 2019
How do I search whether a column, lets say 'Column1', exists in a table, Table_1, without using strmatch as it is not recommended.

  0 Comments

Sign in to comment.

Products

2 Answers

Answer by Kevin Phung on 10 Jul 2019
Edited by Kevin Phung on 10 Jul 2019

any(ismember(Table_1.Properties.VariableNames,'Column1'))
strcmp works too, in place of ismember

  0 Comments

Sign in to comment.


Answer by Shubham Sangle on 10 Jul 2019

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

  0 Comments

Sign in to comment.