How can I get my demos published similar to the way MATLAB demos look?

2 views (last 30 days)
All MATLAB demos have a specific style to them. I would like to make my demos look the same or similar when I publish the MATLAB-files.
For example: MATLAB demos have a blue header on each demo html page with two hyper links. One to edit the code in the MATLAB editor other to run the demo in the command window.
I am trying to integrate my toolbox with the MATLAB help. Similarly under Contents > MATLAB > Demos > Mathematics > Basic Matrix Operations, the page has two links at the top: "Open intro.m in the Editor" and "Run in the Command Window". Given that intro.m doesn't have any explicit HTML in it, I am guessing that some sort of stylesheet is being applied.
However, when I create my own "demos" and publish them, I can't get MATLAB to display the two links at the top. Is there any easy way to do this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 1 Oct 2009
The stylesheets that are used to generate MATLAB demo HTML files are actually not shipped with the product. Hence, it would would be hard to get you the exact stylesheet that is used for publishing our demos.
However, You could write your own stylesheet. Then use this to publish your code for the demos. To this stylesheet you can add whatever you may like and perhaps change a few things as well.
Here is a sample XSL stylesheet based on the basic one that MATLAB uses to publish HTML files. MATLAB uses the mxdom2simplehtml.xsl stylesheet to publish MATLAB-code. This is available in the following directory:
$matlabroot\toolbox\matlab\codetools\private
Where $matlabroot is the MATLAB's installation directory and can be obtained by typing the following at the MATLAB command prompt:
matlabroot
You can make a copy of this file and modified the new file to add the hyperlinks on the top along with the blue colored header. Please see the following steps that use a similarly modified XSL file:
1) copy the attached files mxdom2simplehtml_fordemos.xsl and demo_code.m into the working folder. This is the XSL file which I have modified for demos.
2) Run the following commands to produce the HTML for the demo_code.m. The following statements publish to HTML using a specified XSL stylesheet.
opts.stylesheet = 'mxdom2simplehtml_fordemos.xsl';
publish('demo_code.m' ,opts)
3) The HTML file for your demos will now contain the blue header and hyperlinks that open the same file and run the demo file (see attached sample demo_code.html_
You can customize this easily for your files by opening the mxdom2simplehtml_fordemos.xsl in the MATLAB Editor. The lines of interest would be from line 180-220 in this file. Specifically lines 215 and 218 is where you will need to modify the text to replace it with your MATLAB-filename.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2009b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!