- () parentheses refers to the container array itself
- {} curly braces refers to the content of the array
How to determine if table format value is array or cell?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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'}
0 comentarios
Respuestas (1)
Stephen23
el 17 de Dic. de 2021
Editada: Stephen23
el 17 de Dic. de 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:
0 comentarios
Ver también
Categorías
Más información sobre Data Type Identification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!