An entirely new type of script has been introduced in MATLAB as of Version 2016a. The script is called a live script and is created using the Live Editor. A live script is much more dynamic than a simple script; it can embed equations, images, and hyperlinks in addition to formatted text. Instead of having graphs in separate windows, the graphics are shown next to the code that created them. It is also possible to put the graphs inline, under the code. The scripts that we have seen so far have been simple scripts, stored in files that have an extension of .m. Live scripts are instead stored using the .mix file format.
An example of a live script is shown in Fig. 1. In this live script named “sintest.mix,” there is text, followed by an equation, then code, more text, another equation, and more code. All of these are in separate sections. The sections are created by clicking on “code,” “text,” “equation” and so forth from the “Insert” section, with “section break” in between each type of section. All output, including error messages if there are any, are shown to the right of the code. In this case, the graphs produced by the code sections are shown to the right of the code. Clicking on the icon above the graphs will move them inline. There are several ways to create a live script. The simplest is to click on New, then Live Script. A simple script can also be transformed into a live script by choosing Save As and then Live Script. Right clicking on a set of commands from the Command History window also pops up an option to save as a Live Script.
All of the code from the live script can be executed by choosing the Run All button. Alternatively, individual sections can be executed by clicking on the bar to the left of the section as seen in Fig. 2.
Once a live script has been completed, it can be shared with others as an.mix file, or it can be converted to a PDF or HTML format. To do this, click on the down arrow under “Save,” and then either “Export to PDF” or “Export to HTML.” Live scripts can also be converted to code files with the .m extension by choosing Save As and then choosing MATLAB Code file from the drop down menu for the Format.