Editor's Note: This file was selected as MATLAB Central Pick of the Week
This is intended to be a simple way to display 2D or 3D table data with support for row and column labels.
It can also save the HTML code to a file, which can then be used elsewhere.
The function supports nested tables.
Gus Brown (2021). Display data as an HTML table (https://www.mathworks.com/matlabcentral/fileexchange/18329-display-data-as-an-html-table), MATLAB Central File Exchange. Retrieved .
Inspired: HTMLtable
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Works great for me, thanks!
This is really good! I used to use all HTML code in Matlab and it's really hard to add more input. Thank you so much!
there is a little bug in line 111, the index on colorFlag is missing: instead if colorFlag apply colorFlag(j).
this is so beautiful, i really like it and hope could be upgraded to display much more things like diagrams.
Thanks for the detailed comments, it is really great to get that sort of feedback.
As for your preference for property value pairs, I would likely agree with you. However this was written as an experiment in 'freeform' input. Basically I wanted to be able to leave out certain inputs and have the function still be able to make sense of what is there.
For example, the first argument is normally the table title, but this can be left out, in which case the data becomes the first argument. The same applies to the format specifiers.
To answer your question...
The string 'flags' can be mixed case but they cannot be shortened. They can appear anywhere after the data. Which means that you cannot have a single column named 'save' because it will be seen as a flag, but I can live with that.
It now downloads properly. A very nice idea, well written, with good code.
My preference, with this many optional arguments, would have been to use a property/value pair interface. Its only a preference though.
The help is quite readable, at least when displayed using help. The examples are themselves in HTML. Ok, I'll admit I'm an HTML dinosaur, so when I looked at the examples in the editor as a flat text file, they were hard to read. Of course, if you are using this code, you probably know more about HTML than me anyway. IMHO, I also found the help to be slightly non-standard, at least according to my own standards. It was quite readable anyway.
I had one question that remained unanswered from the help. The latter arguments are intended to be character strings, as flags. Does capitalization matter? Can they be in any order? Can they be shortened, as long as that shortening is unambiguous? For example, instead of 'save','show', can you use 'Sh','sav'?
Because of the question above, part of me wanted to rate this a 4.5. It is really nice though, so I rounded up to 5.
I have Zipped the file to avoid any download problems. I think the presence of HTML code in the file prevents it from being downloaded correctly.
I have re-uploaded the file.
Gus, This looks interesting but your m-file seems to have gotten garbled in the upload. Please re-load.
Thanks
Matt W.