How to Create Signals using Live Editor Task
Learn how to Create Signals using a Live Editor Task in MATLAB®. This allows you to create a numerical, logical or enumeration type signal and output it as data array, time series, time table, or vector. Once you create your signal, you can save it to the MATLAB® workspace, and use it in a Simulink® model to run simulations.
Published: 13 Sep 2022
CreateSignalLiveTask is a new addition to the Live Editor in R2022b. In this video, you'll see how to create a signal using the Live Task, save it to the MATLAB workspace, and then use it in an electric vehicle example to run drive cycle simulations. Signals created through this Live Task can be used with a number of source blocks, applications, and workflows.
In the MATLAB window use New Live Script to launch the Live Editor tool strip. Using the Task menu, launch the Create Signal Live Task from the SIMULINK INPUTS AND OUTPUTS category. You can use this to create Numerical, Logical, and Enumeration type signals, and the output format for the signal can be a data array, timeseries, timetable, or a vector. You can create the signal using drag to draw data points in a freehand manner, drag to insert a line, click or tap to insert a point. You can also use the drag to erase points to erase any points that don't fit your need. You can see all these changes in the table and edit Time and Data points directly.
Let's create a vehicle speed signal with respect to time. Start at 0 speed, ramp up to 35 miles per hour, and stay at the speed for a few seconds. Then ramp up to 55 miles per hour and stay at the speed for a few more seconds. Then ramp down and come to a stop.
To see the signal you created check the Display results Plot box. If you open up the section below, you can see the script associated with creating the signal. Once you have completed the changes, run the script to save the signal to the MATLAB workspace. Now let's see how you can import this into the electric vehicle example. You can access the electric vehicle example from the Simulink start page under Powertrain Blockset.
The newly created vehicle speed signal can be used as a drive cycle source. Enter the signal name and select the units. And since this is a short cycle, select Repeat cyclically, and then Run a simulation.
Once the simulation completes, you can monitor the results. As you can see, the drive cycle ran five times. This shows how you can create a signal using the Live Task. To learn more, visit the Documentation pages.