Merge Variables in Table
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Alexandra Kopaleyshvili
am 12 Jun. 2021
Bearbeitet: Alexandra Kopaleyshvili
am 13 Jun. 2021
I would like to create a for loop which can merge variables dynamically by first letter, excluding the number standing behind the letter.
from this:
to this:
Thanks!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 13 Jun. 2021
names = YourTable.Properties.VariableNames;
initials = extractBefore(names, 2);
[G, id] = findgroups(initials);
newTable = table();
for K = 1 : length(id)
newTable.(id{K}) = [YourTable{:,G==K}];
end
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!