Stateflow^{®} charts in Simulink^{®} models have an action language property that defines the syntax that you use to compute with vectors and matrices. The action language properties are:
MATLAB^{®} as the action language.
C as the action language.
For more information, see Differences Between MATLAB and C as Action Language Syntax.
In charts that use MATLAB as the action language, refer to elements of a vector or matrix by using onebased indexing delimited by parentheses. Separate indices for different dimensions with commas.
In charts that use C as the action language, refer to elements of a vector or matrix by using zerobased indexing delimited by brackets. Enclose indices for different dimensions in their own pair of brackets.
Example  MATLAB as the Action Language  C as the Action Language 

The first element of a vector V  V(1)  V[0] 
The i ^{th} element
of a vector V  V(i)  V[i1] 
The element in row 4 and column
5 of a matrix
M  M(4,5)  M[3][4] 
The element in row i and column
j of a matrix
M  M(i,j)  M[i1][j1] 
This table summarizes the interpretation of all binary operations on vector and matrix operands according to their order of precedence (1 = highest, 3 = lowest). Binary operations are left associative so that, in any expression, operators with the same precedence are evaluated from left to right. Except for the matrix multiplication and division operators in charts that use MATLAB as the action language, all binary operators perform elementwise operations.
Operation  Precedence  MATLAB as the Action Language  C as the Action Language 

 1  Matrix multiplication.  Elementwise multiplication. For matrix multiplication,
use the 
 1  Elementwise multiplication.  Not supported. Use the operation 
 1  Matrix right division.  Elementwise right division. For matrix right division,
use the 
 1  Elementwise right division.  Not supported. Use the operation 
 1  Matrix left division.  Not supported. Use the 
 1  Elementwise left division.  Not supported. Use the 
 2  Addition.  Addition. 
 2  Subtraction.  Subtraction. 
 3  Comparison, equal to.  Comparison, equal to. 
 3  Comparison, not equal to.  Comparison, not equal to. 
 3  Not supported. Use the operation  Comparison, not equal to. 
 3  Not supported. Use the operation  Comparison, not equal to. 
This table summarizes the interpretation of all unary operations and actions on vector and matrix operands. Unary operations:
Have higher precedence than the binary operators.
Are right associative so that, in any expression, they are evaluated from right to left.
Perform elementwise operations.
Example  MATLAB as the Action Language  C as the Action Language 

 Logical NOT. For bitwise NOT, use the 

 Not supported. Use the operation
 Logical NOT. 
 Negative.  Negative. 
 Not supported.  Increment all elements of the vector or matrix. Equivalent
to 
 Not supported.  Decrement all elements of the vector or matrix. Equivalent
to 
This table summarizes the interpretation of assignment operations on vector and matrix operands.
Operation  MATLAB as the Action Language  C as the Action Language 

 Simple assignment.  Simple assignment. 
 Not supported. Use the expression  Equivalent to 
 Not supported. Use the expression  Equivalent to 
 Not supported. Use the expression  Equivalent to 
 Not supported. Use the expression  Equivalent to 
You can assign a value to an individual entry of a vector or matrix by using the syntax appropriate to the action language of the chart.
Example  MATLAB as the Action Language  C as the Action Language 

Assign the value 10 to the first
element of the vector V .  V(1) = 10;  V[0] = 10; 
Assign the value 77 to the element in row 2 and column 9
of the matrix M .  M(2,9) = 77;  M[1][8] = 77; 
In charts that use MATLAB as the action language, you can specify all of the elements of a
vector or matrix in a single statement. For example, this action assigns each
element of the 2by3 matrix A
to a different
value:
A = [1 2 3; 4 5 6];
In charts that use C as the action language, you can use scalar expansion to
set all of the elements of a vector or matrix to the same value. For example,
this action sets all of the elements of the matrix A
to
10
:
A = 10;