MATLAB: Equivalent of isfield for tables

isfieldtable

I'd like to know if my Matlab table has a particular column. If it was a structure I'd use isfield. Is there a built in function for this?

Best Answer

I would also like to suggest using ismember()
For instance:
f1 = 1; f2 = 10; t = table(f1,f2)
t =
f1 f2
__ __
1 10
ismember('f1', t.Properties.VariableNames)
logical
1
It also works for a range of values:
ismember({'f0','f1','f2'}, t.Properties.VariableNames)
1×3 logical array
0 1 1