Live Editor tasks are apps 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.
Tasks represent a series of MATLAB® commands. You can display their output either inline or on the right. To see the MATLAB commands that the task runs, show the generated code.
To add a task to a live script, go to the Live Editor tab, click Task , and select from the available tasks. You also can type the name of the task in a live script code block. As you type, the Live Editor displays possible matches, and you can select and insert the desired task. For example, create a live script that creates a vector of data containing an outlier.
A = [57 59 60 100 59 58 57 58 300 61 62 60 62 58 57];
Add the Create Plot task to your live script to plot the vector of data.
Add the Clean Outlier Data task to your live
script to smooth the noisy data and avoid skewed results. To add the task, start
typing the word
clean in the live script and select
Clean Outlier Data from the suggested command completions. In
the task, set Input data to
A. The task
identifies and fills two outliers in the data and creates the variable
cleanedData in the MATLAB workspace with the stored results. You also can see the results in the
output plot for the task. Continue modifying additional parameters until you are
satisfied with the results.
To restore all parameter values back to their defaults, click the options button at the top-right of the task and select Restore Default Values.
When you are done modifying parameters, you can collapse the task to help with readability. To collapse the task, click the arrow at the top-left of the task.
The task displays as a single, user-readable line of pseudocode with output.
To delete a task, click the task and then press Delete or Backspace. You also can place your cursor directly before or after the task and use the Delete or Backspace key, respectively.
By default, as you modify the value of parameters in the task, the task and
current section (including other tasks in the section) run automatically. This
ensures that the results and surrounding code in the section remain up to date. For
example, in the live script
cleanmydata.mlx, the entire section
including the code that creates the vector of noisy data reruns every time you
modify the value of a parameter in the Clean Outlier Data task. To run only the
task, add section breaks before and after the task. For more information about
sections and how to add section breaks, see Run Sections in Live Scripts.
A green circular icon at the top-right of the task indicates that the task runs automatically when you modify the task parameters.
To disable running the section automatically, click the autorun icon. The icon updates to display the disabled state. To run the task and current section, on the Live Editor tab, click the Run Section button.
Some tasks do not run automatically by default. This default setting ensures optimal performance for those tasks.
To modify the name of the output argument, click the text box containing the argument name and enter a new name.
You can use the resulting output argument in subsequent code, including as inputs to additional Live Editor tasks.
To see the MATLAB commands that the task runs, click the options button at the top-right of the task and select either Controls and Code or Code Only. You also can use the down arrow at the bottom of the task to show and hide the generated code. The generated code is read-only.
To edit the generated code, click the options button and select Convert Task to Editable Code. This option removes the task and replaces it with the generated code, which you then can edit.