display a matrix that contains strings and numbers
3 次查看(过去 30 天)
显示 更早的评论
hi
take for example the following:
nameMatrix = {'abc';'ef'}
dataMatrix = [ 1 2 3; 4 5 6]
fullMatrix = {nameMatrix,dataMatrix}
if i want to display the full matrix st i get the following
abc 1 2 3
ef 4 5 6
how can i do that so that they are perfectly aligned. if i use celldisp dont get them aligned..
thanks
0 个评论
采纳的回答
Walter Roberson
2012-3-28
fullMatrix = [char(nameMatrix), num2str(dataMatrix)];
3 个评论
Walter Roberson
2012-3-29
char([nameMatrix; num2str(dataMatrix)])
However, if you want the names to align with the numbers, then the easiest way is to start using fprintf()
更多回答(0 个)
另请参阅
类别
在 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!