Simulink Reference    
From Workspace

Read data from the workspace

Library

Sources

Description


The From Workspace block reads data from the MATLAB workspace. The block's Data parameter specifies the workspace data via a MATLAB expression that evaluates to a matrix (2-D array) or a structure containing an array of signal values and time steps. The format of the matrix or structure is the same as that used to load inport data from the workspace (see Loading Input from the Base Workspace"). The From Workspace icon displays the expression in the Data parameter.

The From Workspace block's Interpolate data parameter determines the block's output in the time interval for which workspace data is supplied. If the Interpolate data option is selected, the block interpolates between data values for time steps that occur between the times for which data is supplied from the workspace. Otherwise, the block uses the most recent data value supplied from the workspace.

The block's Form output after final data value by parameter determines the block's output after the last time step for which data is available from the workspace. The following table summarizes the output block based on the options that the parameter provides.

Form
Output Option

Interpolate Option

Block Output After Final Data
Extrapolate
On
Extrapolated from final data value
Extrapolate
Off
Error
SettingToZero
On
Zero
SettingToZero
Off
Zero
HoldingFinalValue
On
Final value from workspace
HoldingFinalValue
Off
Final value from workspace
CyclicRepetition
On
Error
CyclicRepetition
Off
Repeated from workspace. This option is valid only for workspace data in structure-without-time format.

If the input array contains more than one entry for the same time step, Simulink uses the signals specified by the last entry. For example, suppose the input array has this data:

At time 2, the output is 5, the signal value for the last entry for time 2.

Data Type Support

A From Workspace block accepts real or complex signals of any type except int64 and uint64 from the workspace. Real signals of type double can be in either structure or matrix format. Complex signals and real signals of any type other than double must be in structure format.

Parameters and Dialog Box

Data
An expression that evaluates to an array or a structure containing an array of simulation times and corresponding signal values. For example, suppose that the workspace contains a column vector of times named T and a vector of corresponding signal values named U. Entering the expression [T,U] for this parameter yields the required input array. If the required signal-versus-time array or structure already exists in the workspace, enter the name of the structure or matrix in this field.
Sample time
Sample rate of data from the workspace. See Specifying Sample Time in the online documentation for more information.
Interpolate data
This option causes the block to linearly interpolate at time steps for which no corresponding workspace data exists. Otherwise, the current output equals the output at the most recent time for which data exists.
Form output after final data value by
Select method for generating output after the last time point for which data is available from the workspace.

Characteristics

Sample Time
Inherited from driven block
Scalar Expansion
No
Dimensionalized
Yes
Zero Crossing
No


  From File Function-Call Generator