Enhancing Tables with Gareth
Today we have a guest post by Gareth Thomas. Gareth is Academic Marketing Manager for the Education Business in the MathWorks. He aims to inspire people of all ages about technology and share the magic that MathWorks brings to the table when learning, teaching, researching and solving problems that accelerate the pace of engineering and science. You can find Gareth on LinkedIn and Google+.
Enhancing Table Reporting in MATLAB
by Gareth Thomas
Today I want to talk about sharing tables in reports (a table is a relatively new data type in MATLAB suitable for column-oriented or tabular data). In the current release of MATLAB (R2014a) it can be a little tricky to represent a table variable in an HTML document. So I’m going to show you how to take the reporting capabilities that MATLAB currently offers, combine them with some HTML 5 and JavaScript, and end up with a beautiful report that functions nicely as a standalone document.
Today there are basically two different ways to create HTML reports from MATLAB.
- MATLAB’s publish command
- The MATLAB Report Generator
The publish command ships with MATLAB, while the Report Generator is a product dedicated to the creation of sophisticated reports from MATLAB. Beyond this, the key difference between the two methods really comes down to when you want to deploy your algorithm. That is, do you want the report to update itself in real time? If you want to create a standalone executable, you can really only use the Report Generator.
I’m going to focus on MATLAB’s publish command. Suppose you want to pass a lot of MATLAB-generated HTML into your published document. It turns out that you can use the disp command to add that HTML code into the generated document. However it is not really easy to pass arguments, as this HTML is hard coded at publish time. To get around this I created a function (makeHTMLTableFilter) that creates HTML code that, when published, is also dynamic and responsive. It achieves this by adding Javascript code. This allows you to do things like filter the table interactively.
See the example below:
This is a very nice way of sharing your results in a form of a table while allowing others to filter the fields that they wish.
One question that I get is, “Okay, but how would I deploy this?” As it happens, this idea of using
disp(makeHTMLTableFilter(mytable))
is also supported in the MATLAB Report Generator.
So download makeHTMLTableFilter and give it a try. You’ll soon be making interactive reports of your own.
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.