How to generate repeat column labels
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi
I'm looking to create column labels for my table:
array2table(data,'VariableNames',{'FirstName' 'Height' 'Weight' 'BloodPressure'})
I want the variable names to be Cell 1, Cell 2, Cell 3, Cell 4, etc. until Cell 100. How can I generate these repeat character strings without typing it out manually? Thanks.
댓글 수: 0
채택된 답변
추가 답변 (1개)
Atsushi Ueno
2022년 5월 21일
text = sprintf('Cell %d\n',1:100);
text(end) = []; % to avoid an empty cell at the end
labels = splitlines(text);
array2table(1:100,'VariableNames',labels)
댓글 수: 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!