Rules for Using Complex Data in C Charts
Complex data is data whose value is a complex number. For example, in a Stateflow® chart in Simulink® model, an input signal with the value 3 + 5i
is
complex. See Complex Data in Stateflow Charts.
These rules apply when you use complex data in Stateflow charts that use C as the action language.
Do not use complex number notation in actions
C charts do not support complex number notation (a + bi)
, where
a
and b
are real numbers. Therefore, you
cannot use complex number notation in state actions, transition conditions and
actions, or any statements in C charts.
To define a complex number, use the complex
operator as
described in Notation for Complex Data.
Do not perform math function operations on complex data in C charts
Mix complex and real operands only for addition, subtraction, and
multiplication
If you mix operands for any other math operations in C charts, an error appears
when you try to simulate your model.
To mix complex and real operands for division, you can use a MATLAB function as described in Perform Complex Division with a MATLAB Function.
Tip
Another way to mix operands for division is to use the
complex
, real
, and
imag
operators in C charts.
Suppose that you want to calculate y = x1/x2
, where
x1
is complex and x2
is real. You can
rewrite this calculation as:
y = complex(real(x1)/x2, imag(x1)/x2)
For more information, see Access Real and Imaginary Parts of a Complex Number.
Do not define complex data with constant scope
If you define complex data with Constant
scope, an
error appears when you try to simulate your model.
Do not define complex data with ml
, struct
,
or boolean
base type
If you define complex data with ml
,
struct
, or boolean
base
type, an error appears when you try to simulate your model.
Use only real values to set initial values of complex data
When you define the initial value for data that is complex, use only a real value.
See Additional Properties for instructions on
setting an initial value in the Data properties dialog box.
Do not enter minimum or maximum values for complex data
In the Data properties dialog box, do not enter any values in the
Minimum or Maximum field when you
define complex data. If you enter a value in either field, an error message appears
when you try to simulate your model.
Assign complex values only to data of complex type
If you assign complex values to real data types, an error appears when you try to
simulate your model.
Note
You can assign both real and complex values to complex data types.
Do not pass real values to function inputs of complex type
This restriction applies to the following types of chart functions:
Graphical functions
Truth table functions
MATLAB functions
Simulink functions
If your C chart passes real values to function inputs of complex type, an error
appears when you try to simulate your model.
Do not use complex data with temporal logic operators
You cannot use complex data as an argument for temporal logic operators, because
you cannot define time as a complex number.
Related Topics