Converting table elements to individual arrays and assigning the same header
30 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Akshay
am 25 Jan. 2023
Kommentiert: Akshay
am 26 Jan. 2023
I have an n x 85 table and I'm looking for a way to assign each of these individual columns to a separate array under the same existing header name (all string). table2array(T) let's me convert the table to individual arrays but I want to run a for loop in order to assign the same header to each of these newly created arrays. I've extracted the header names using the following where T is my table: table_names = T.Properties.VariableNames.
Not sure how to now assign this name to the rest of the numeric data from each column on the table.
Any help would be greatly appreciated!
1 Kommentar
Akzeptierte Antwort
Michael Habermann
am 25 Jan. 2023
Bearbeitet: Michael Habermann
am 25 Jan. 2023
t = table();
t.col_a = [1;2;3];
t.col_b = [10;11;12]
column_names = t.Properties.VariableNames;
for i = 1:numel(column_names)
colname = string(column_names(i));
eval(sprintf("%s = t.(colname)", colname))
end
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!