Write data to workspace
Simulink / Sinks
HDL Coder / Sinks
The To Workspace block writes input signal data to a workspace. During simulation, the block writes data to an internal buffer. When you pause the simulation or the simulation completes, that data is written to the workspace. Data is not available until the simulation pauses or stops.
The To Workspace block typically writes data to the MATLAB® base workspace. For a sim
command in a MATLAB function, the To Workspace block sends data to the
workspace of the calling function, not to the MATLAB base workspace. To send the logged data to the base workspace, use an
assignin
command in the function.
function myfunc a = sim('mTest','SimulationMode','normal'); b = a.get('simout') assignin('base','b',b); end
The To Workspace block icon shows the name of the variable to which the data is written.
If you specify data logging intervals with the Configuration Parameters > Data Import/Export > Logging intervals parameter, the To Workspace block does not log data
outside of the intervals. For example, the block logs no data if the intervals are
empty ([]
). The block stores the logged data in the variable that
you specify for the Single simulation output parameter.
For variable-step solvers, to control the amount of data available to the
To Workspace block, use the Configuration Parameters > Data Import/Export > Additional parameters > Output options parameter. For example, to write data at identical time points over
multiple simulations, select the Produce specified output only
option.
Block parameters also control the amount of data saved. See Limit data points to last, Decimation, and Sample time.
When you enable the MAT-file logging parameter in Configuration Parameters, the To Workspace block logs its data to a MAT-file. For information about this parameter, see MAT-file logging (Simulink Coder).
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
To make post-processing easier, you can convert data saved by this block to
Dataset
format. This conversion is useful when post
processing this data with other logged data that can use
Dataset
format (for example, logged states). See Convert Logged Data to Dataset Format. You can also use signal logging with
a variable-size signal exception.