To display examples such as videos, published program scripts, or other files that illustrate the use of your programs in the MATLAB® help browser, follow these steps:
Create your example files. Store the files in a folder that is on the
MATLAB search path, but outside the
folder. matlabroot
Tip
MATLAB includes a feature that converts scripts or functions to formatted HTML files, which you can display as examples. To create these HTML files in MATLAB, use either of these two methods:
Create a live script (*.mlx
) and export
it to HTML. For more information, see Share Live Scripts and Functions.
Create a script (*.m
), and publish it
to HTML. For more information, see Publish and Share MATLAB Code.
Create a demos.xml
file that describes the name, type,
and display information for your examples. Place the file in the folder (or
a subfolder of the folder) that contains your info.xml
file. For more information about creating an info.xml
file, see Display Custom Documentation.
For example, suppose that you have a toolbox named My
Sample
, which contains a script named
my_example
that you published to HTML. This
demos.xml
file allows you to display
my_example
:
<?xml version="1.0" encoding="utf-8"?> <demos> <name>My Sample</name> <type>toolbox</type> <icon>HelpIcon.DEMOS</icon> <description>This text appears on the main page for your examples.</description> <website><a href="https://www.mathworks.com">Link to your Web site</a></website> <demosection> <label>First Section</label> <demoitem> <label>My Example Title</label> <type>M-file</type> <source>my_example</source> </demoitem> </demosection> </demos>
Note
<demosection>
elements are optional.
View your examples.
In the Help browser, navigate to the home page.
At the bottom of the page, under Supplemental Software click the link for your example.
Your example opens in the main help window.
Within the demos.xml
file, the root tag is
<demos>
. This tag includes elements that determine
the contents of the main page for your examples.
XML Tag | Notes |
---|---|
| Name of your toolbox or collection of examples. |
| Possible values are |
| Ignored in MATLAB R2015a and later. In previous
releases, this icon was the icon for your example. In those
releases, you can use a standard icon,
|
| The description that appears on the main page for your examples. |
| (Optional) Link to a website. For example, MathWorks® examples include a link to the product page at
|
Optionally, define categories for your examples by including a
<demosection>
for each category. If you include
any categories, then all examples
must be in categories.
Each <demosection>
element contains a
<label>
that provides the category name, and the
associated <demoitem>
elements.
XML Tag | Notes |
---|---|
| Defines the title to display in the browser. |
| Possible values are Typically, if you published your example using
the publish function, the appropriate
|
| If |
| Use this element only for examples with a
|
| Use this element only for examples with a
|
| (Optional) Specifies other products required to run the
example, such as another toolbox. The text must match a
product name specified in an |