Add Interactive Tasks to a Live Script in MATLAB

Live Editor tasks are simple point-and-click interfaces that can be added to a live script to perform a specific set of operations. You can add tasks to live scripts to explore parameters and automatically generate code. Use tasks to reduce development time, errors, and time spent plotting.

We are familiar with Jupyter notebook in Python. In MATLAB, there are live scripts. MATLAB live scripts and live functions are interactive documents that combine MATLAB code with formatted text, equations, and images in a single environment called the Live Editor. In addition, live scripts store and display output alongside the code that creates it.

The live scripts are better than Jupyter notebook in some ways. Here is an example.

We use the “Reduce data dimensionality using PCA “ task as an example.

Principal component analysis (PCA) is a popular technique for analyzing large datasets containing a high number of dimensions/features per observation, increasing the interpretability of data while preserving the maximum amount of information, and enabling the visualization of multidimensional data.

First, we must create a live script. Then load the data of HVSR, which is a microtremor method.

Next, we add the PCA task from the menu list “Task”.

The PCA task is as below, which contains the Select data, Specity dimensionality reduction criterion , and Display results. All functions in an interactive interface. You can also see the source code by clicking the small triangle.

Finally, we can set the output style. The outputs can display on the right or inline.

In summary, the task in the live script is very convenient. Hope this helps you!