table variable name based on array
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Azura Hashim
il 29 Lug 2016
Commentato: Azura Hashim
il 30 Lug 2016
Hi, is it possible to assign table variable name based on strings in an array. For example:
colnames={'a' 'b'};
a=[1;2];
b=[3;4];
c=table();
c.colnames{1}=a;
c.colnames{2}=b;
Thank you.
0 Commenti
Risposta accettata
Più risposte (1)
Steven Lord
il 29 Lug 2016
Set the VariableNames of the table when you create it.
colnames = {'a' 'b'};
a = [1;2];
b = [3;4];
c = table(a, b, 'VariableNames', colnames)
Or change them later by assigning to the VariableNames property of the table.
newnames = {'Alice', 'Bob'};
c.Properties.VariableNames = newnames
Vedere anche
Categorie
Scopri di più su Tables in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!