Products & Services Solutions Academia Support User Community Company

eml.nullcopy - Declare uninitialized variables

Syntax

X = eml.nullcopy(A)

Description

X = eml.nullcopy(A) copies type, size, and complexity of A to X, but does not copy element values. Preallocates memory for X without incurring the overhead of initializing memory.

Use With Caution

Use this function with caution. See Rules for Declaring Uninitialized Variables in the Embedded MATLAB User's Guide documentation.

Example

The following example shows how to declare variable X as a 1-by-5 vector of real doubles without performing an unnecessary initialization:

function X = foo

N = 5;
X = eml.nullcopy(zeros(1,N));
for i = 1:N
   if mod(i,2) == 0
      X(i) = i;
   else
      X(i) = 0;
   end
end

Using eml.nullcopy with zeros lets you specify the size of vector X without initializing each element to zero.

See Also

Uninitialized Variables

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2010- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS