UNINIT - Create an uninitialized variable (like ZEROS but faster)

版本 1.0.0.0 (7.2 KB) 作者: James Tursa
UNINIT is similar to ZEROS, except UNINIT returns uninitialized values instead of zero values.
1.1K 次下载
更新时间 2011/5/9

查看许可证

UNINIT is very similar to the ZEROS function, except that UNINIT returns an uninitialized array instead of a zero-filled array. Thus, UNINIT is faster than the ZEROS function for large size arrays. Since the return variable is uninitialized, the user must take care to assign values to the elements before using them. UNINIT is useful for preallocation of an array where you know the elements will be assigned values before using them.

Syntax (nearly identical to the ZEROS function)

B = uninit
B = uninit(n)
B = uninit(m,n)
B = uninit([m n])
B = uninit(m,n,p,...)
B = uninit([m n p ...])
B = uninit(size(A))
B = uninit(m, n,...,classname)
B = uninit([m,n,...],classname)
B = uninit(m, n,...,complexity)
B = uninit([m,n,...],complexity)
B = uninit(m, n,...,classname,complexity)
B = uninit([m,n,...],classname,complexity)

Description

B = uninit
Returns a 1-by-1 scalar uninitialized value.

B = uninit(n)
Returns an n-by-n matrix of uninitialized values. An error message
appears if n is not a scalar.

B = uninit(m,n) or B = uninit([m n])
Returns an m-by-n matrix of uninitialized values.

B = uninit(m,n,p,...) or B = uninit([m n p ...])
Returns an m-by-n-by-p-by-... array of uninitialized values. The
size inputs m, n, p, ... should be nonnegative integers. Negative
integers are treated as 0.

B = uninit(size(A))
Returns an array the same size as A consisting of all uninitialized
values.

If any of the numeric size inputs are empty, they are taken to be 0.

The optional classname argument can be used with any of the above.
classname is a string specifying the data type of the output.
classname can have the following values:
'double', 'single', 'int8', 'uint8', 'int16', 'uint16',
'int32', 'uint32', 'int64', 'uint64', 'logical', or 'char'.
(Note: 'logical' and 'char' are not allowed in the ZEROS function)
The default classname is 'double'.

The optional complexity argument can be used with any of the above.
complexity can be 'real' or 'complex', except that 'logical' and 'char'
outputs cannot be complex. (this option not allowed in the ZEROS function)
The default complexity is 'real'.

UNINIT is typically self building. That is, the first time you call UNINIT, the uninit.m file recognizes that the mex routine needs to be compiled and then the compilation will happen automatically. UNINIT uses the undocumented MATLAB API function mxCreateUninitNumericMatrix. It has been tested in PC WinXP versions R2006b through R2011a, but may not work in future versions or non-PC versions of MATLAB.

引用格式

James Tursa (2024). UNINIT - Create an uninitialized variable (like ZEROS but faster) (https://www.mathworks.com/matlabcentral/fileexchange/31362-uninit-create-an-uninitialized-variable-like-zeros-but-faster), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2006b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Arithmetic Operations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0