Detect cell entries in MATLAB Table -
i have matlab table (the new 'table' class), let's call a
:
a=table([1;2;3],{'a';'b';'c'})
as can see, of columns double, cell.
i'm trying figure out ones cells.
for reason, there no a.properties.class
can use, , can't seem call iscell
on it.
what's "matlab" way of doing this? have loop through each column of table figure out class?
one approach -
out = cellfun(@(x) iscell(getfield(a,x)),a.properties.variablenames)
or, better way access fields(variables) dynamically -
out = cellfun(@(x) iscell(a.(x)), a.properties.variablenames)
sample runs:
run #1 -
a=table([1;2;3],{4;5;6}) = var1 var2 ____ ____ 1 [4] 2 [5] 3 [6] out = 0 1
run #2 -
>> a=table([1;2;3],{'a';'b';'c'}) = var1 var2 ____ ____ 1 'a' 2 'b' 3 'c' out = 0 1
run #3 -
>> a=table([1;2;3],{4;5;6},{[99];'a';'b'},{'m';'n';'p'}) = var1 var2 var3 var4 ____ ____ ____ ____ 1 [4] [99] 'm' 2 [5] 'a' 'n' 3 [6] 'b' 'p' >> out out = 0 1 1 1
Comments
Post a Comment