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 sltypesize
Home > sltoolbox > utils > sltypesize.m

sltypesize

PURPOSE ^

SLTYPESIZE Gets the element size of a specified type

SYNOPSIS ^

function s = sltypesize(typename)

DESCRIPTION ^

SLTYPESIZE Gets the element size of a specified type

 $ Syntax $
   - s = sltypesize(typename)

 $ Arguments $
   - typename:         the name of a type
   - s:                the number of bytes in each element of the specified type

 $ Description $

   - s = sltypesize(typename) returns the number of bytes of each element
     in the type specified by typename.

   - 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 s = sltypesize(typename)
0002 %SLTYPESIZE Gets the element size of a specified type
0003 %
0004 % $ Syntax $
0005 %   - s = sltypesize(typename)
0006 %
0007 % $ Arguments $
0008 %   - typename:         the name of a type
0009 %   - s:                the number of bytes in each element of the specified type
0010 %
0011 % $ Description $
0012 %
0013 %   - s = sltypesize(typename) returns the number of bytes of each element
0014 %     in the type specified by typename.
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 switch typename
0036     case 'double'
0037         s = 8;
0038     case {'single', 'float'}
0039         s = 4;
0040     case {'uint8', 'int8'}
0041         s = 1;
0042     case {'uint16', 'int16'}
0043         s = 2;
0044     case {'uint32', 'int32'}
0045         s = 4;
0046     case {'uint64', 'int64'}
0047         s = 8;
0048     case {'char', 'logical'}
0049         s = 1;
0050     otherwise
0051         error('sltoolbox:invalid_type', ...
0052             'Unsupported typename %s', typename);
0053 end
0054

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

Contact us at files@mathworks.com