{"id":2730,"date":"2014-06-09T11:40:36","date_gmt":"2014-06-09T16:40:36","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=2730"},"modified":"2016-11-27T13:47:07","modified_gmt":"2016-11-27T18:47:07","slug":"enhancing-tables-with-gareth","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2014\/06\/09\/enhancing-tables-with-gareth\/","title":{"rendered":"Enhancing Tables with Gareth"},"content":{"rendered":"<p><em>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 <a href=\"https:\/\/www.linkedin.com\/in\/gareth-thomas-5b6ba710\">LinkedIn<\/a> and <a href=\"\">Google+<\/a>.<br \/>\n<\/em><\/p>\n<h1>Enhancing Table Reporting in MATLAB<\/h1>\n<p><em>by Gareth Thomas<\/em><\/p>\n<p>Today I want to talk about sharing tables in reports (a <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/tables.html\">table<\/a> 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&#8217;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.<\/p>\n<p>Today there are basically two different ways to create HTML reports from MATLAB.<\/p>\n<ol>\n<li>MATLAB&#8217;s <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/publish.html\">publish<\/a> command<\/li>\n<li>The <a href=\"https:\/\/www.mathworks.com\/products\/ML_reportgenerator\/\">MATLAB Report Generator<\/a><\/li>\n<\/ol>\n<p>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.<\/p>\n<p>I&#8217;m going to focus on MATLAB&#8217;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 <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/disp.html\">disp<\/a> 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 (<a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/46181-makehtmltablefilter\">makeHTMLTableFilter<\/a>) 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.<\/p>\n<p>See the example below:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/tables.png\" alt=\"tables\" width=\"600\" height=\"434\" class=\"alignnone size-full wp-image-2731\" \/><\/p>\n<p>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.<\/p>\n<p>One question that I get is, &#8220;Okay, but how would I deploy this?&#8221; As it happens, this idea of using<\/p>\n<p><code>disp(makeHTMLTableFilter(mytable))<\/code><\/p>\n<p>is also supported in the MATLAB Report Generator.<\/p>\n<p>So download <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/46181-makehtmltablefilter\">makeHTMLTableFilter<\/a> and give it a try. You&#8217;ll soon be making interactive reports of your own.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/tables.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>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&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2014\/06\/09\/enhancing-tables-with-gareth\/\">read more >><\/a><\/p>\n","protected":false},"author":69,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/2730"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/69"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=2730"}],"version-history":[{"count":28,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/2730\/revisions"}],"predecessor-version":[{"id":4277,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/2730\/revisions\/4277"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=2730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=2730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=2730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}