| Stateflow | ![]() |
ml Namespace Operator
The ml namespace operator uses standard dot (.) notation to reference MATLAB variables and functions in action language. For example, the statement y = ml.x returns the value of the MATLAB workspace variable x to the Stateflow data y. The statement y = ml.matfunc(arg1, arg2) passes the return value from the MATLAB function matfunc to Stateflow data y.
If the MATLAB function you call does not require arguments, you must still include the parentheses, as shown in the preceding examples. If the parentheses are omitted, Stateflow interprets the function name as a workspace variable, which, when not found, generates a run-time error during simulation.
In the following examples, x, y, and z are workspace variables and d1 and d2 are Stateflow data:
sin function of MATLAB evaluates the sine of x, which is then assigned to Stateflow data variable a. However, because x is a workspace variable, you must use the namespace operator to access it. Hence, ml.x is used instead of just x.
sin function of MATLAB evaluates the sine of d1, which is assigned to Stateflow data variable a. Because d1 is Stateflow data, you can access it directly.
x. If x does not exist prior to simulation, it is automatically created in the MATLAB workspace.
x and y are arrays. x[1][3] is the (1,3) element of the two-dimensional array variable x. y[3] is the third element of the one-dimensional array variable y. The last argument, 'string', is a literal string.
The return from the call to matfunc is assigned to element (5,6,7) of the workspace array, v. If v does not exist prior to simulation, it is automatically created in the MATLAB workspace.
| MATLAB Functions and Data | ml Function | ![]() |