File Exchange

image thumbnail

Display N-dimensional data tables (with color highlighting)

version (8.02 KB) by Matt Caywood
Legible display of N-dimensional data tables with color highlighting of entries.

1 Download

Updated 12 Apr 2017

View License

DisplayTable offers many more options than Matlab's built-in matrix display functions, when it comes to matrices/tables that are 3+ dimensional.
DisplayTable prints out a space-saving, legible N-dimensional table of numeric data including:
* dimension (row and column) labels and headings
* specified cell spacing and precision
* display dimensions in any order by specifying an output permutation!
* highlight cells with any colors you want, using the cprintf function (also on Matlab Central)! Note: cprintf relies on undocumented Matlab features.

Sample call:

displaytable(rand(5,5),{'1' '2'},{{'C1' 'C2' 'C3' 'I1' 'I2'},{'C1' 'C2' 'C3' 'I1' 'I2'}})

Will display:

1/2 C1 C2 C3 I1 I2
C1 0.76 0.71 0.82 0.44 0.49
C2 0.74 0.03 0.69 0.38 0.45
C3 0.39 0.28 0.32 0.77 0.65
I1 0.66 0.05 0.95 0.80 0.71
I2 0.17 0.10 0.03 0.19 0.75

Comments and Ratings (7)

Hi Charles, did you try the sample call I just added to description above?

I try to send the function without the optional values, and I get errors like 'colheadings must be a cell array of string'. The documentation says that it can be an empty cell. What am I doing wrong? I get other errors for the incorrect use without optional inputs.


how to download the diaplaytable function?


This is a great utility, I just have one feature request: the ability to have the contents of a column left justified. Thanks!

Hi Ralf, "negative zero" was actually a fundamental issue with Matlab's printf (on some platforms)

I agree it is an annoyance, and have submitted a new version that should fix it.


I like this function very much. However, it appears that 0 is displayed sometimes as -0. Can this been fixed?

Good utility code.


updated documentation

improved documentation

fix negative zero issue

fixed header spacing

added color display of tables

added option for table permutations

Fixed some problems with degenerate tables with dimension values = 1

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: simulate motion in Cartesian MRI

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor