How to align names with the numbers in a matrix?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello!
I have to put heading row over the data matrix so I used the following code:
a=[12 13 14];
b={'a'; 'b'; 'c';};
c=[char(b)'; num2str(a)]
it gives me:
C= abc
12 13 14
But I want to align the first row over the second one.
required output:
C= a b c
12 13 14
댓글 수: 2
David Fletcher
2021년 4월 5일
Can't you use a table - using the entries in b as the VariableNames and a as the row data
채택된 답변
Karanvir singh Sohal
2021년 4월 6일
추가 답변 (1개)
Walter Roberson
2021년 4월 5일
a=[12 13 14];
b={'a'; 'b'; 'c';};
fprintf('%5s %5s %5s\n', b{:}); fprintf('%5d %5d %5d\n', a);
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!