- () 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?
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Stephen23
le 17 Déc 2021
Modifié(e) : Stephen23
le 17 Déc 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 commentaires
Voir également
Catégories
En savoir plus sur Data Type Identification dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!