Declare uninitialized variables in code generation
copies type, size, and complexity of X
= coder.nullcopy(A
)A
to X
, but
does not copy element values. The function preallocates memory for X
without incurring the overhead of initializing memory. In code generation, the
coder.nullcopy
function declares uninitialized variables. In
MATLAB®, coder.nullcopy
returns the input such that X is equal
to A.
If X is a structure containing variable-sized arrays, then you must assign the size
of each array. coder.nullcopy
does not copy sizes of arrays or nested
arrays from its argument to its result.
Before you use X
in a function or a program,
ensure that the data in X
is
completely initialized . Declaring a variable through
coder.nullcopy
without assigning
all the elements of the variable results in
nondeterministic program behavior. For more information, see How to Eliminate Redundant Copies by Defining Uninitialized Variables.
You cannot use coder.nullcopy
on sparse matrices.