Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slinitarray
Home > sltoolbox > core > slinitarray.m

slinitarray

PURPOSE ^

SLINITARRAY Initialize an array of specified type and size

SYNOPSIS ^

function A = slinitarray(type, size)

DESCRIPTION ^

SLINITARRAY Initialize an array of specified type and size

 $ Syntax $
   - A = slinitarray(type, size)

 $ Arguments $
   - type          the string representing the element type of the array
   - size          the vector representing the size of the array
   - A             the initialized array

 $ Description $
   - A = slinitarray(type, size) creates an array of specified type and
     given size, with all elements being zeros.

   - The typenames supported are listed below:
       - 'double'      
       - 'single'
       - 'float'
       - 'uint8'
       - 'uint16'
       - 'uint32'
       - 'uint64'
       - 'int8'
       - 'int16'
       - 'int32'
       - 'int64'
       - 'logical'
       - 'char'

 $ History $
   - Created by Dahua Lin on Dec 7th, 2005

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:

SOURCE CODE ^

0001 function A = slinitarray(type, size)
0002 %SLINITARRAY Initialize an array of specified type and size
0003 %
0004 % $ Syntax $
0005 %   - A = slinitarray(type, size)
0006 %
0007 % $ Arguments $
0008 %   - type          the string representing the element type of the array
0009 %   - size          the vector representing the size of the array
0010 %   - A             the initialized array
0011 %
0012 % $ Description $
0013 %   - A = slinitarray(type, size) creates an array of specified type and
0014 %     given size, with all elements being zeros.
0015 %
0016 %   - The typenames supported are listed below:
0017 %       - 'double'
0018 %       - 'single'
0019 %       - 'float'
0020 %       - 'uint8'
0021 %       - 'uint16'
0022 %       - 'uint32'
0023 %       - 'uint64'
0024 %       - 'int8'
0025 %       - 'int16'
0026 %       - 'int32'
0027 %       - 'int64'
0028 %       - 'logical'
0029 %       - 'char'
0030 %
0031 % $ History $
0032 %   - Created by Dahua Lin on Dec 7th, 2005
0033 %
0034 
0035 
0036 switch type
0037     case 'double'
0038         A = zeros(size);
0039     case {'single', 'float'}
0040         A = zeros(size, 'single');
0041     case {'uint8', 'uint16', 'uint32', 'uint64', ...
0042           'int8', 'int16', 'int32', 'int64'}
0043         A = zeros(size, type);
0044     case 'logical'
0045         A = false(size);
0046     case 'char'
0047         A = char(zeros(size, 'uint8'));
0048     otherwise
0049         error('sltoolbox:invalid_type', ...
0050             'Unsupported typename %s', typename);
0051 end
0052

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com