Stateflow | ![]() ![]() |
Stateflow data of type ml
is typed internally with the MATLAB type mxArray
. This means that you can assign (store) any type of data available in Stateflow to a data of type ml
. This includes any type of data defined in Stateflow or returned from MATLAB with the ml
namespace operator or ml
function.
The following features and limitations apply to Stateflow data of type ml
.
ml
data can be initialized from the MATLAB workspace just like other data in Stateflow (see the Initialize from property in Setting Data Properties).
ml
data in Stateflow can participate in any kind of unary operation and any kind of binary operation with any other data in Stateflow.
ml
data participates in any numerical operation with other data, the size of the ml
data must be inferred from the context in which it is used, just as return data from the ml
namespace operator and ml
function are. See Inferring Return Size for ml Expressions.
Note
The preceding feature does not apply to ml data storing MATLAB 64 bit integers. ml data can store 64 bit MATLAB integers but cannot be used in Stateflow action language.
|
ml
.
ml
data can be used in building a simulation target (sfun
) but not in building an RTW target (rtw
).
ml
contains an array, the elements of the array can be accessed through indexing with the following rules:
This means that only one-dimensional arrays can be accessed by a single index value. You cannot access a multidimensional array with a single index value.
mldata
is a Stateflow data of type ml
, ws_num_array
is a 2-by-2 MATLAB workspace array with numerical values, and ws_str_array
is a 2-by-2 MATLAB workspace array with string values.
ml
data cannot have a scope outside Stateflow; that is, it cannot be scoped as Input to Simulink or Output to Simulink.
Place Holder for Workspace Data
Both the ml
namespace operator and the ml
function can access data directly in the MATLAB workspace and return it to Stateflow. However, maintaining data in the MATLAB workspace can present Stateflow users with conflicts with other data already resident in the workspace. Consequently, with the ml
data type, you can maintain ml
data in Stateflow and use it for MATLAB computations in Stateflow action language.
As an example, in the following Stateflow action language statements, mldata1
and mldata2
are Stateflow data of type ml
:
In the first line of this example, mldata1
receives the return value of the rand
function in MATLAB, which, in this case, returns a 3-by-3 array of random numbers. Note that mldata1
is not specified as an array or sized in any way. It can receive any MATLAB workspace data or the return of any MATLAB function because it is defined as a Stateflow data of type ml
.
In the second line of the example, mldata2
, also of Stateflow data type ml
, receives the transpose matrix of the matrix in mldata1
. It is assigned the return value of the MATLAB function transpose
in which mldata1
is the argument.
Note the differences in notation if the preceding example were to use MATLAB workspace data (wsdata1
and wsdata2
) instead of Stateflow ml
data to hold the generated matrices:
In this case, each workspace data must be accessed through the ml
namespace operator.
![]() | Which ml Should I Use? | Inferring Return Size for ml Expressions | ![]() |