In the MATLAB® language, data can vary in size. By contrast, the semantics of generated code constrains the class, complexity, and shape of every expression, variable, and structure field. Therefore, for code generation, you must use each variable consistently. Each variable must:
Be either complex or real (determined at first assignment)
Have a consistent shape
For fixed-size data, the shape is the same as the size returned
in MATLAB. For example, if size(A) == [4 5]
,
the shape of variable A
is 4 x 5. For variable-size
data, the shape can be abstract. That is, one or more dimensions can
be unknown (such as 4x?
or ?x?
).
By default, the compiler detects code logic that attempts to change these fixed attributes after initial assignments, and flags these occurrences as errors during code generation. However, you can override this behavior by defining variables or structure fields as variable-size data.
For more information, see Bounded Versus Unbounded Variable-Size Data