Merge Variables in Table
    조회 수: 2 (최근 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에서 Tables에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

