Filter löschen
Filter löschen

display a matrix that contains strings and numbers

3 Ansichten (letzte 30 Tage)
eliza
eliza am 28 Mär. 2012
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 28 Mär. 2012
fullMatrix = [char(nameMatrix), num2str(dataMatrix)];
  3 Kommentare
Walter Roberson
Walter Roberson am 29 Mär. 2012
char([nameMatrix; num2str(dataMatrix)])
However, if you want the names to align with the numbers, then the easiest way is to start using fprintf()
eliza
eliza am 29 Mär. 2012
thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by