How to covert rownames to the first variable in the table?
36 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
monkeyquant
am 25 Jan. 2023
Beantwortet: Star Strider
am 25 Jan. 2023
I have a table with rownames (nuemric value) and want to convert it to a table with a newly added variable from the rownames.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 25 Jan. 2023
Try something like this —
T1 = array2table(randi(9, 5, 5));
T1.Properties.RowNames = {'1','2','3','4','5'} % Create Table With Row Names
RN = T1.Properties.RowNames % Get Row Names
T1 = addvars(T1, cell2mat(RN), 'Before','Var1') % Convert Row Names To First Variable
T1.Properties.RowNames = {} % Delete Original Row Names
.
0 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!