coder.nullcopy
Declare uninitialized variables in code generation
Syntax
Description
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 or a class 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.
Note
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.
Examples
Input Arguments
Limitations
You cannot use
coder.nullcopy
on sparse matrices.You cannot use
coder.nullcopy
with classes that support overloaded parentheses or require indexing methods to access their data, such astable
.
Extended Capabilities
Version History
Introduced in R2011a