Add Column and Row Labels to Matrix
336 次查看(过去 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!