Compactly display a matrix

If we wish to display a matrix using the command 'disp' in a compact manner, I know we can use "format compact" to minimize vertical space wastage in the command window.
Similarly, if we wish to reduce the horizontal space between the columns of a matrix while displaying it using 'disp', is there a simple way already available in Matlab?
I know we can use the printf commands along with carefully constructed formatting strings, but if I just need to reduce the horizontal space between the columns, is there a simple way?
Thanks!

回答(2 个)

Matt Fig
Matt Fig 2011-4-12

0 个投票

For this kind of thing I wrote my own custom display function, which uses the FPRINTF command for the formatting. I don't know of any other way to reduce horizontal spacing.
Par
Par 2011-4-12

0 个投票

Thanks Matt. I also found a function "displaytable" in the Matlab file exchange, which does a pretty good job. I am currently using this, but I just wanted to know if there is any other way available using only the regular Matlab functions.

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

提问:

Par
2011-4-12

Community Treasure Hunt

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

Start Hunting!

Translated by