Merge Variables in Table
1 回表示 (過去 30 日間)
古いコメントを表示
Alexandra Kopaleyshvili
2021 年 6 月 12 日
編集済み: Alexandra Kopaleyshvili
2021 年 6 月 13 日
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 件のコメント
採用された回答
Walter Roberson
2021 年 6 月 13 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!