add column in table
92 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
T= struct2table(G);
c=1:length(T);
c=c';
i want to add c as new column of T!
0 Kommentare
Akzeptierte Antwort
Voss
am 11 Jul. 2023
G = struct('ones',{1 1 1 1},'twos',{2 2 2 2}); % for example
T= struct2table(G);
c=1:height(T); % use height
c=c';
T.new_column = c
7 Kommentare
Voss
am 12 Jul. 2023
[Is it] possible [to] move c in the first column?
Yes, see below:
G = struct('ones',{1 1 1 1},'twos',{2 2 2 2}); % for example
T= struct2table(G);
c=1:height(T); % use height
c=c';
T.new_column = c;
T = T(:,[end 1:end-1])
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!