Skip to Main Content Skip to Search
Product Documentation

Operations That Work with Vectors and Matrices in Stateflow Action Language

Binary Operations

You can perform element-wise binary operations on vector and matrix operands of equal dimensions in the following order of precedence (1 = highest, 3 = lowest). For operations with equal precedence, they evaluate in order from left to right.

Example

Precedence

Description

a * b

1

Multiplication

a / b

1

Division

a + b

2

Addition

a - b

2

Subtraction

a == b

3

Comparison, equality

a != b

3

Comparison, inequality

The multiplication and division operators in Stateflow action language perform element-wise operations, not standard matrix multiplication and division. For more information, see Using MATLAB Functions to Perform Matrix Multiplication and Division.

Unary Operations and Actions

You can perform element-wise unary operations and actions on vector and matrix operands.

Example

Description

~a

Unary minus

!a

Logical NOT

a++

Increments all elements of the vector or matrix by 1

a--

Decrements all elements of the vector or matrix by 1

Assignment Operations

You can perform element-wise assignment operations on vector and matrix operands.

Example

Description

a = expression

Simple assignment

a += expression

Equivalent to a = a + expression

a -= expression

Equivalent to a = a - expression

a *= expression

Equivalent to a = a * expression

a /= expression

Equivalent to a = a / expression

  


Free Stateflow Interactive Kit

Learn how engineers use Stateflow to model state machines in their Simulink models.


Get free kit

Trials Available

Try the latest version of Stateflow.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS