I am new to Matlab. Is there a way to use printmat to print 2 words heading?
Example result as followed:
Title One Title Two
Well, the documentation of printmat tells you that
PRINTMAT(A,NAME,RLAB,CLAB) prints the matrix A with the row labels RLAB and column labels CLAB. NAME is a string used to name the
matrix. RLAB and CLAB are string variables that contain the row
and column labels delimited by spaces.
So spaces in the title are not natively supported.
As a workaround, you can use another separator that "looks like a space", for example, the unit separator:
printmat (
matA, '', 'one two', ...
['Title' char(31) 'One Title' char(31) 'Two Title' char(31) 'Three']);
output:
Test =
Title One Title Two Title Three
one 11.00000 22.00000 33.00000
two 22.00000 33.00000 44.00000
But as you see, this gets awkward real fast. It will also probably not look right when printed to file or some other output than the Matlab command window (terminal, for instance). You'll have to experiment a bit.
Personally I would just write my own, more general pretty-printer using cells and sprintf with specific field-widths in the format string, as suggested by H.Muster (+1).