How to determine if table format value is array or cell?

13 views (last 30 days)
I have a table format variable tbl. When I read csv file I get for same column name values in array or cell formats. How can I test if value in table variable is array or cell format? I have tried commands like iscell(tbl(10,'MEAN(area)')) but I get 0 output for both cases. Command istable gives 1 output for both. So, I am trapped with the automated decision... :-(
tbl(10,'MEAN(area)')
ans =
table
MEAN(area)
__________
70.552
tbl(10,'MEAN(area)')
ans =
table
MEAN(area)
_____________________
{'81.13460234701654'}

Answers (1)

Stephen23
Stephen23 on 17 Dec 2021
Edited: Stephen23 on 17 Dec 2021
Summary: you need to use curly braces to refer to the content of a table.
Explanation: tables are a container class: they are arrays which contain arrays of other classes. So it is very important to distinguish between the table itself (or a subtable of it using parentheses indexing) which is a container, and the content stored within the table. How to refer to parts of the table itself (i.e. to the container) vs. how to refer to its contents (e.g. numeric, text, datetime, etc.) is explained here:
Instead of trying to refer to a table itself you need to refer to the content of the table, e.g. using the variable/column name or by using indexing with curly braces
tbl{10,'MEAN(area)'}
% ^ ^ curly braces refer to table content
The same logic applies to other container classes: structures, strings, cell arrays:
  • () parentheses refers to the container array itself
  • {} curly braces refers to the content of the array

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!