Display Custom Examples

How to Display Examples

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:

  1. Create your example files. Store the files in a folder that is on the MATLAB search path, but outside the matlabroot folder.

      Tip   MATLAB includes a publishing feature that converts scripts or functions to formatted HTML files, which you can display as examples. For information about creating these HTML files, see Publishing MATLAB Code.

  2. Create a demos.xml file that describes the name, type, and display information for your examples.

    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 and a MATLAB video:

    <?xml version="1.0" encoding="utf-8"?>
        <name>My Sample</name>
        <description>This text appears on the main page for your examples.</description>
        <website><a href="">Link to your Web site</a></website>
            <label>First Section</label>
                <label>My Example Title</label>
            <label>Second Section</label>
                <label>My Video (5 min, 21 sec)</label>

      Note:   <demosection> elements are optional.

  3. View your examples.

    1. In the Help browser, navigate to the home page.

    2. At the bottom of the page, under Supplemental Software click the link for your example.

      Your example opens in the main help window.

Elements of the demos.xml File

General Information in <demos>

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.




Name of your toolbox or collection of examples.


Possible values are matlab, simulink, toolbox, or blockset.


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, HelpIcon.DEMOS. Or, you can provide a custom icon by specifying a path to the icon relative to the location of the demos.xml file.


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

Categories Using <demosection>

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.

Information About Each Example in <demoitem>




Defines the title to display in the browser.


Possible values are M-file, model, M-GUI, video, or other.

Typically, if you published your example using the publish function, the appropriate <type> is M-file.


If <type> is M-file, model, M-GUI, then <source> is the name of the associated .m file or model file, with no extension. Otherwise, do not include a <source> element, but include a <callback> element.


Use this element only for examples with a <type> value other than M-file when you want to display an HTML file that describes the example. Specify a relative path from the location of demos.xml.


Use this element only for examples with a <type> value of video or other to specify an executable file or a MATLAB command to run the example.


(Optional) Specifies other products required to run the example, such as another toolbox. The text must match a product name specified in an info.xml file that is on the search path or in the current folder.

Was this topic helpful?