| Stateflow User's Guide | ![]() |
Which ml Should I Use?
In most cases the notation of the ml namespace operator is more straightforward. However, using the ml function call does offer a few advantages:
The following example creates four new MATLAB matrices:
This example demonstrates the use of a Stateflow for loop to create four new matrix workspace variables in MATLAB. The default transition initializes the Stateflow counter i to 0 while the transition segment between the top two junctions increments it by 1. If i is less than 5, the transition segment back to the top junction is taken and evaluates the ml function call ml('A%d = rand(%d)',i,i) for the current value of i. When i is greater than or equal to 5, the transition segment between the bottom two junctions is taken and execution stops.
This results in the following MATLAB commands, which create a workspace scalar (A1) and three matrices (A2, A3, A4):
You cannot use full MATLAB notation with the ml namespace operator, as demonstrated by the following example:
This example sets the workspace variable A to a magic 4-by-4 matrix using the ml namespace operator. Stateflow data B is then set to the addition of A and its transpose matrix, A', which produces a symmetric matrix. Because the ml namespace operator cannot evaluate the expression A', the ml function is used instead. However, you can call the MATLAB function transpose with the ml namespace operator in the following equivalent expression:
As another example, you cannot use arguments with cell arrays or subscript expressions involving colons with the ml namespace operator. However, these can be included in an ml function call.
| ml Expressions | ml Data Type | ![]() |
© 1994-2005 The MathWorks, Inc.