Mike on the MATLAB Desktop

February 7th, 2011

Demo’ing Scripts With ECHODEMO

Scripting files in Cell Mode has plenty of benefits. In addition to code organization, rapid iteration, and publishing, cell mode can also be used to present cell-by-cell interactive demonstrations.

Many of the demo files that come with MATLAB are written as cell mode scripts. This allows us to publish them into the doc, but did you know there is also an interactive way to view cell mode demos? Take a look at demos such as penny, integerMath, or nddemo. To browse our script demos, use the demos command. You can open a demo in the editor with edit or in the help browser with showdemo.

However you can run through a demo one cell at a time in the Command Window with echodemo. Each cell is displayed in turn with the cell’s text printed out and the code executed. The cell’s paragraph text is displayed with hyperlinks for moving to the next cell or stopping the demo. One advantage to showing demos in this is fashion is that since you are at the Command Window, you can run additional code or query variables at each step.

The PENNY demo through ECHODEMO

One Response to “Demo’ing Scripts With ECHODEMO”

  1. EBS replied on :

    ECHODEMO is neat, but it doesn’t work very well when the cell’s text is longer than the height of the command window – the header gets scrolled off the screen so you can’t access the hyperlinks to get to the next cell without some manual scrolling back and forth…

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks
Mike works on the MATLAB Desktop team.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.