Write event-based signal to workspace
This block writes its input to a structure or array in the base MATLAB® workspace when the simulation stops or pauses. One way to pause a running simulation is to select Simulation > Pause. Suspending the simulation during a debugger session does not cause this block to write data to the workspace. This block logs data at each sample time hit.
This block is similar to the To Workspace block in the Simulink® Sinks library but is tailored for use with event-based signals.
The Save format parameter determines the output format. The Structure With Time output format is most appropriate for event-based signals because it indicates when the signal assumes each value. Updates of event-based signals are typically aperiodic.
If the signal has an initial value, the value is the first data value in the workspace variable. (An example of a signal that has no initial value is a signal inside an Atomic Subsystem that has an event-based input signal.) Depending on the topology of your model, initial values of the signal might account for multiple data values in the workspace variable.
To identify the first data value that represents a sample time hit of the event-based signal, insert the Initial Value block before this block. Set the Value until the first sample time hit parameter to a value you do not expect as a signal value at a sample time hit. To identify the initial value or values of the signal, remove the Initial Value block.
For scalar signals, you can convert a structure with time into a two-column matrix containing times in the first column and signal values in the second column. To do this, use an assignment like the one below. In place of simout, use the name specified in this block's Variable name parameter.
times_values = [simout.time, simout.signals.values];
For descriptions of all output formats, see the reference page for the To Workspace block.
This block has no Sample time parameter because event-based signals do not have a true sample time.
The simulation times at which this block records data is typically unrelated to the variable that a model creates if you select Time in the Save to workspace section of the Data Import/Export tab of the Configuration Parameters dialog box. By default, this option is selected and the variable is called tout.
This block has one signal input port for the signal to write to the workspace.
The block has no entity ports, and no signal output port.
The name of the structure or array that holds the data.
The maximum number of input samples to be saved.
A positive integer, n, that specifies the decimation factor. The block ignores the last n–1 out of every n input samples.
Format in which to save simulation output to the workspace. The recommended format for event-based signals is Structure With Time.