# Finding Cell Records in a MATLAB Table

I have a Matlab table (new class "Table"), call it `A`

:

```
A=table([1;2;3],{'A';'B';'C'})
```

As you can see, some of the columns are double, some are cells.

I am trying to figure out which ones are cells.

For some reason there is no `A.Properties.class`

one I can use and I cannot name `iscell`

on it.

What's the "Matlab" way to do this? Do I need to iterate over each column of the table to figure out its class?

+3

source to share

2 answers

One approach -

```
out = cellfun(@(x) iscell(getfield(A,x)),A.Properties.VariableNames)
```

Or a better way would be to access the fields (variables) dynamically in the same way -

```
out = cellfun(@(x) iscell(A.(x)), A.Properties.VariableNames)
```

Examples of run:

Launch # 1 -

```
A=table([1;2;3],{4;5;6})
A =
Var1 Var2
____ ____
1 [4]
2 [5]
3 [6]
out =
0 1
```

Startup No. 2 -

```
>> A=table([1;2;3],{'A';'B';'C'})
A =
Var1 Var2
____ ____
1 'A'
2 'B'
3 'C'
out =
0 1
```

Launch # 3 -

```
>> A=table([1;2;3],{4;5;6},{[99];'a';'b'},{'m';'n';'p'})
A =
Var1 Var2 Var3 Var4
____ ____ ____ ____
1 [4] [99] 'm'
2 [5] 'a' 'n'
3 [6] 'b' 'p'
>> out
out =
0 1 1 1
```

+3

source to share