1

I have some matrices and I'd like to print them using printmat. I only have column names for them so I don't need the row labels (also I don't know how much rows there are).

So I tried:

printmat(test,'test name','','test1 test2 test3 test4')

But it told me

Error using printmat (line 66)
Not enough row labels.

What can I do now? Thx.

Natalia
  • 369
  • 3
  • 15
  • 1
    Might be worth your while checking out the new [table](http://blogs.mathworks.com/loren/2013/09/10/introduction-to-the-new-matlab-data-types-in-r2013b/#fe5c445a-1e68-4a44-ab40-d9cc90438539) data type – Dan Jul 15 '14 at 11:13

1 Answers1

0

You could do it manually, but then you need to set number formatting and label spacing to match the columns. For example:

>> A = magic(4) %// example data

A =

    16     2     3    13
     5    11    10     8
     9     7     6    12
     4    14    15     1

>> disp(['  test1     test2     test3     test4'; num2str(A, '%0.4f   ')])

  test1     test2     test3     test4
16.0000    2.0000    3.0000   13.0000
 5.0000   11.0000   10.0000    8.0000
 9.0000    7.0000    6.0000   12.0000
 4.0000   14.0000   15.0000    1.0000

Note that incorrect spacing may give a concatenation error. Spacing has to be set manually.

By the way, printmat seems to be obsolete.

Community
  • 1
  • 1
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
  • Thank you so much! "...correct spacing may give a concatenation error" Whant does it mean? – Natalia Jul 15 '14 at 11:27
  • @Natalia I mean: if you introduce an extra space in the string `' test1...'` for example, the result will not be simply bad aligned; it will not show at all (you can't vertically contatenate strings of different lengths) – Luis Mendo Jul 15 '14 at 11:29
  • @Natalia Exactly. Or you could write code to do it automatically, but it'd be a little tricky – Luis Mendo Jul 15 '14 at 11:34
  • that seems a little inconvenient..by the way, do I have to `num2str`? – Natalia Jul 15 '14 at 11:37