Add Column and Row Labels to Matrix
조회 수: 358 (최근 30일)
이전 댓글 표시
I'd like to add string data column and row labels (aka "headers") to a 5x13 matrix. I've expanded the matrix to 6x14 with NaNs to accommodate these labels on both the x and y.
I've tried the below threads' approaches, and I'm apparently missing something in each case, and am unable to modify to get them to work for me: https://www.mathworks.com/matlabcentral/newsreader/view_thread/245987 https://www.mathworks.com/matlabcentral/answers/89195-how-to-put-heading-for-columns-of-matrix
I'm really trying to stay out of the Excel world. Truly, I am... but this one is making that temptation hard to resist.
Thank you, everyone.
댓글 수: 0
채택된 답변
KL
2017년 5월 16일
편집: KL
2017년 5월 16일
sample = rand(3,3);
rowNames = {'a','b','c'};
colNames = {'x','y','z'};
sTable = array2table(sample,'RowNames',rowNames,'VariableNames',colNames)
댓글 수: 3
RISHABH RISHABH
2021년 5월 22일
What to do if there are 100 columns as if there are 3 like above, we can easily name them as a,b,c. but i have a matrix which has 100 columns and 20 rows. help please
Stuart McGarrity
2021년 5월 27일
sample=rand(20,100);
rowNames="row_"+ (1:20)'; % Doubles get converted to strings when they are concatenated with them
colNames="col_"+ (1:100);
sTable = array2table(sample,'RowNames',rowNames,'VariableNames',colNames);
추가 답변 (1개)
ASHOK BANERJEE
2020년 11월 20일
I have a problem to label a data array as follows:
Air speed Ambient air temperaure (0 C)
v Ta
(km/h) 5 0 -5 -10 -15 -20 -25 -30 -35
15
30 This space to be filled with (Data array) wind chill temperature,(Twc) given
by the formulae
45 Twc=13.112+0.6215*Ta -11.37*v^0.16+0.3965*Ta*v^0.16
60
75
90
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!