How do I define an empty table of unknown size?
Mostra commenti meno recenti
Hi,
I want to define an empty table to fill in a for loop. The size of the table is defined by another variable. How do I define the "VariableType" variable without knowing how many variables there are? In my case they will all be strings. Example:
T = table('Size', [2, numel(Elements)], 'VariableType',["string","string","string","string","string"]);
In this particular cae, numel(Elements) would be 5. But how do I define the table if I don't know numel(Elements) ?
Risposta accettata
Più risposte (1)
Walter Roberson
il 26 Mag 2020
0 voti
Sorry, variables that do not exist do not have any datatype.
As you add variables to the table, the datatype associated with the variable will be the determined by the datatype of the value being assigned. If necessary, string() the value you are assigning into the table.
3 Commenti
Fabrice Lambert
il 26 Mag 2020
Walter Roberson
il 26 Mag 2020
That is not an empty table with an unknown number of variables: that is a table with 2 rows and a known number of variables.
Fabrice Lambert
il 26 Mag 2020
Modificato: Fabrice Lambert
il 26 Mag 2020
Categorie
Scopri di più su Tables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!