Playback
Libraries:
Simulink /
Sources
Description
Use the Playback block to load input data for simulation. The Playback block supports loading real or complex signals with fixed or variable dimensions, discrete and continuous signals, and messages. Using the Playback block, you can load data from:
Workspace variables of any data format supported by the Simulation Data Inspector
Files in the same formats supported by the Record block and the Simulation Data Inspector such as MAT, MLDATX (since R2023a), and Microsoft® Excel® files
Data from a custom file reader
Runs in the Simulation Data Inspector
For more information about workspace variables and file formats supported by the Playback block, see Import Data from Workspace or File into Simulation Data Inspector.
You can also use the Playback block in conjunction with the Record block as part of a record and playback workflow. Use the Record block to record data from physical devices or simulations. Then, use the Playback block to load the recorded data into a model. Using real or simulated data, you can then develop, test, and optimize the model. For more information about the Record block, see Record.
Add Data to Playback Block
You can add signals, messages, multidimensional signals, buses, and arrays of buses to the Playback block. To load data to a model using the Playback block, first add data to the block. Then, select the data to load by assigning signals or messages to ports. When you run a simulation, the Playback block loads data into the model.
To add signals to the Playback block for loading, double-click the block. When you double-click a Playback block that has no signals, the block shows a screen with options to add data.
You can choose from three ways to load data to your model:
Load a workspace variable from the base workspace, model workspace, or mask workspace.
Load data from a file. If the file is not on the MATLAB® path or in your current directory, you can click the folder icon to browse for your data.
Load data from the workspace, a file, or the Simulation Data Inspector using the Add Signals dialog box.
Use the Add Signals dialog box to access more options for loading data from the workspace or a file or to load data from the Simulation Data Inspector.
When you load data from the workspace or a file, you can choose to reference the signals in the source or save a copy of the signals in the model. Loading signal data from the Simulation Data Inspector always saves a copy of the signals in the model.
Referencing the signal in the source links the signal in the Playback block to the variable or file that contains the signal data. If the data in the source variable or file changes, that change is reflected in the data loaded by the Playback block. When linking data, only metadata is stored on the block for each signal.
When you save a copy of the signals in the model, the Playback block loads from the copied data. Changes made to the original data source variable or file are not reflected in the Playback block output.
The Add Signals dialog box also allows you to choose whether to assign ports automatically or manually. If you choose to manually assign ports, you can create ports using the Port Editor and assign ports using the port column of the signal table.
Visualize Data
After you choose the signal data you want to load, you can use the Playback block to visualize the data using a sparklines plot.
By default, a sparkline is created for each signal loaded with the Playback block. If you load input data for a bus, a sparkline is created for each bus element. Multidimensional signals must be converted to channels or frames to visualize the data. Use the check boxes next to each signal name to control which signals are plotted.
Note
You can select or clear the check boxes to change the appearance of the sparklines visualization without affecting which signals the Playback block loads to a model. To control which signals are loaded to the model, use the port column in the table of signals.
To change the appearance of the signal table, click Preferences. In the Preferences dialog box, you can choose which signal properties to display and how to group the data in the signal table. (since R2023b)
View and Edit Signals and Ports
You can view and edit signal properties using the Properties pane in the Playback block.
In the Properties pane, you can edit any row with a white background. The number of editable fields depends on whether you choose to reference the signal in the source or save a copy of the data in the model.
Port properties for the Playback block can be set separately from the signal properties using the Port Editor.
Using the Port Editor, you can add ports, delete ports, and edit port properties. You can also change port assignments using the signal table. By default, port properties are inherited from the signal. However, you can set a port property independently of the signal property. When compatible with the signal property, the port property determines the output of the Playback block. For example, you can convert the units of a signal with assigned measurement by setting the Units property for that port to a different unit of measurement. When the signal units and port units are compatible, the Playback block performs a unit conversion.
The Playback block supports multirate sample times, allowing you to set a different sample time for each port. Port sample times can also be set separately from the signal sample time.
Export Data Added to Playback Block
Since R2023a
You can use the Playback block to aggregate data from the workspace, files, and the Simulation Data Inspector (linked to from the source or saved in the model) and export that data to the workspace or a file. The Playback block exports all data added to the block, even signals that are not assigned to ports. To export all data added to the Playback block:
On the Simulation tab, in the Share section, click Export.
Select Base workspace or File to export the data to the workspace or to a file. You can choose to export the data to the workspace or to a MAT, MLDATX, or Microsoft Excel file.
Click Export.
If you choose to export data to an MLDATX file, you can specify the name of the run using the Exported run name text box.
If you choose to export data to an Excel file, click Options to select meta data to export and specify how time data is exported.
Ports
Output
Parameters
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|