Simulink.RunTimeBlock - Allow Level-2 MATLAB S-function and other MATLAB programs to get information about block while simulation is
running - MATLAB ([original](https://in.mathworks.com/help/simulink/slref/simulink.runtimeblock.html)) ([raw](?raw))
Main Content
Allow Level-2 MATLAB S-function and other MATLAB programs to get information about block while simulation is running
Description
This class allows a Level-2 MATLAB® S-function or other MATLAB program to obtain information about a block. Simulink® software creates an instance of this class or a derived class for each block in a model. Simulink software passes the object to the callback methods of Level-2 MATLAB S-functions when it updates or simulates a model, allowing the callback methods to get block-related information from and provide such information to Simulink software. See Write Level-2 MATLAB S-Functions in Writing S-Functions for more information. You can also use instances of this class in MATLAB programs to obtain information about blocks during a simulation. See Access Block Data During Simulation for more information.
Note
Simulink.RunTimeBlock
objects do not support MATLAB sparse matrices. For example, the following line of code attempts to assign a sparse identity matrix to the run-time object's output port data. This line of code in a Level-2 MATLAB S-function produces an error:
block.Outport(1).Data = speye(10);
Property Summary
Method Summary
Properties
BlockHandle
Description
Block's handle.
CurrentTime
Description
Current simulation time.
NumDworks
Description
Number of data work vectors.
NumOutputPorts
Description
Number of output ports.
NumContStates
Description
Number of continuous states.
NumDworkDiscStates
Description
Number of discrete states. In a MATLAB S-function, you need to use DWorks to set up discrete states.
NumDialogPrms
Description
Number of parameters declared on the block's dialog. In the case of the S-function, it returns the number of parameters listed as a comma-separated list in the dialog box field.
NumInputPorts
Description
Number of input ports.
NumRuntimePrms
SampleTimes
Description
Block's sample times.
Access
RW
for MATLAB S-functions, RO
for all other blocks.
Methods
ContStates
Purpose
Get a block's continuous states.
Syntax
states = ContStates();
Description
Get vector of continuous states.
DataTypeIsFixedPoint
Purpose
Determine whether a data type is fixed point.
Syntax
bVal = DataTypeIsFixedPoint(dtID);
Arguments
dtID
Integer value specifying the ID of a data type.
Description
Returns true
if the specified data type is a fixed-point data type.
DatatypeName
Purpose
Get the name of a data type.
Syntax
name = DatatypeName(dtID);
Arguments
dtID
Integer value specifying ID of a data type.
Description
Returns the name of the data type specified by dtID
.
DatatypeSize
Purpose
Get the size of a data type.
Syntax
size = DatatypeSize(dtID);
Arguments
dtID
Integer value specifying the ID of a data type.
Description
Returns the size of the data type specified by dtID
.
Derivatives
Purpose
Get derivatives of a block's continuous states.
Syntax
derivs = Derivatives();
Description
Get vector of state derivatives.
DialogPrm
Purpose
Get an S-function's dialog parameters.
Syntax
param = DialogPrm(pIdx);
Arguments
pIdx
Integer value specifying the index of the parameter to be returned.
Description
Get the specified dialog parameter. In the case of the S-function, each DialogPrm
corresponds to one of the elements in the comma-separated list of parameters in the S-function parameters dialog field.
Dwork
Purpose
Get one of a block's DWork vectors.
Syntax
dworkObj = Dwork(dwIdx);
Arguments
dwIdx
Integer value specifying the index of a work vector.
Description
Get information about the DWork vector specified by dwIdx
where dwIdx
is the index number of the work vector. This method returns an object of type Simulink.BlockCompDworkData.
FixedPointNumericType
Purpose
Get the properties of a fixed-point data type.
Syntax
eno = FixedPointNumericType(dtID);
Arguments
dtID
Integer value specifying the ID of a fixed-point data type.
Description
Returns an object of embedded.Numeric
class that contains the attributes of the specified fixed-point data type.
Note
embedded.Numeric
is also the class of thenumerictype
objects created by Fixed-Point Designer™ software. For information on the properties defined byembedded.Numeric
class, see numerictype Object Properties (Fixed-Point Designer).
InputPort
Purpose
Get an input port of a block.
Syntax
port = InputPort(pIdx);
Arguments
pIdx
Integer value specifying the index of an input port.
Description
Get the input port specified by pIdx
, where pIdx
is the index number of the input port. For example,
returns the first input port of the block represented by the run-time object rto
.
This method returns an object of type Simulink.BlockPreCompInputPortData or Simulink.BlockCompInputPortData, depending on whether the model that contains the port is uncompiled or compiled. You can use this object to get and set the input port's uncompiled or compiled properties, respectively.
OutputPort
Purpose
Get an output port of a block.
Syntax
port = OutputPort(pIdx);
Arguments
pIdx
Integer value specifying the index of an output port.
Description
Get the output port specified by pIdx
, where pIdx
is the index number of the output port. For example,
returns the first output port of the block represented by the run-time object rto
.
This method returns an object of type Simulink.BlockPreCompOutputPortData or Simulink.BlockCompOutputPortData, depending on whether the model that contains the port is uncompiled or compiled, respectively. You can use this object to get and set the output port's uncompiled or compiled properties, respectively.
RuntimePrm
Purpose
Get an S-function's run-time parameters.
Syntax
param = RuntimePrm(pIdx);
Arguments
pIdx
Integer value specifying the index of a run-time parameter.
Description
Get the run-time parameter whose index is pIdx
. This run-time parameter is a Simulink.BlockData object of type Simulink.BlockRunTimePrmData.
Version History
Introduced before R2006a