Get from Ico-github-logo

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Printing Variables to HTML Tables in Published Code

  • Printing Variables to HTM...
  • makeHtmlTable(M, T, rowNa...
    MAKEHTMLTABLE Display matrix contents as an HTML table
  • View all files
3.9 | 7 ratings Rate this file 15 Downloads (last 30 days) File Size: 402 KB File ID: #14453 Version: 1.5
image thumbnail

Printing Variables to HTML Tables in Published Code


Ned Gulley (view profile)


28 Mar 2007 (Updated )

This file lets you display variables as HTML tables in your published MATLAB files.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

One often-requested feature for Cell Mode publishing is to have a command that simply displays the output of a MATLABĀ® variable as a table. This file shows how to do that.


This file inspired Im2html.M.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
14 Sep 2016 Brian Kehn

This doesn't work on R1014b either. I get the same output as "Lefteris" did in 2013.

Comment only
17 May 2013 Jonathan Lee

For tables in publish mode I'm using:

f = figure(1);
set(f,'Position',[500 500 300 150]);
dat = {' a', 1, ' units';...
' b', 2, ' units';...
' c', 3, ' units';...
' d', 4, ' units';...
' e', 5, ' units';...
' f', 6, ' units';};
columnname = {'Parameter', 'Value', 'Units'};
columnformat = {'char', 'numeric', 'char'};
t = uitable('Units','normalized','Position',...
[0.05 0.05 0.755 0.87], 'Data', dat,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...

Comment only
22 Mar 2013 Lefteris

Seems nice but does not work in R2013a.
It gives me smt like
I guess it is similar problem to Anna's. Any idea how to overcome it?

Comment only
22 Feb 2013 Anna

Anna (view profile)

I too was having trouble using this code to publish tables while using 2012a. I found an old version of the mxdom2simplehtml.xsl stylesheet from 2007a, and it works well with this code.

Comment only
09 Oct 2012 Fuad

Fuad (view profile)

Hi, when I use this code and publish the table comes out without any borders or any sort of style that I set. I believe its being overwritten by the stylesheet that the publish function uses. Is there any way to modify this behaviour so that the table is properly formatted?

(I'm using R2012a)

15 Feb 2012 Matt G

Matt G (view profile)

12 Jun 2011 Alexander Brodsky

great work.
also I had a problem with displaying table with other display options. for example when I used disp, fprintf, sprintf after or before making html table function, the table not generated in HTML file. For example:
disp('Hello World')

do you met this before and how to overcome it ?

06 Nov 2009 Herve

Herve (view profile)

The nanmin.m and nanmax.m files can be downloaded here :
It could be nice if Ned adds these two files in his distribution.

28 Aug 2009 Daniel Armyr

Daniel Armyr (view profile)

Awsome potential, but it eems to depend on a function called nanmin which is not included in basic Matlab. Either include an implementation, or post a link to an implementation that is compatible.

23 Feb 2009 Brian

Brian (view profile)

This did what I was looking for. I needed to publish an HTML table in a web page. I modified it for my purposes so I could input a format string instead of a precision.

06 Jan 2009 Johanne Hammervold

This seems to be exactly what I need to solve a certain problem with my script. Is it any way to use this code on Matlab R2008b ?


Comment only
25 Jan 2008 kwadwo Dompreh

couldn't output the tables when used

12 Jun 2009 1.1

Minor formatting change.

12 Jun 2009 1.2

Fix copyright line.

15 Jun 2009 1.3

Updated copyright line.

28 Mar 2013 1.4

BGCOLOR attribute for table cells has been deprecated in HTML. Switched code to use STYLE's BACKGROUND attribute instead.

17 Aug 2015 1.5

Moving to GitHub

Contact us