sizeof.m

来自「Serial Application of GPS」· M 代码 · 共 39 行

M
39
字号
function s = sizeof(type)
% SIZEOF Number of bytes in a given precision specification

persistent typemap initialized

% Set up the type map if we haven't already done so
if (isempty(initialized))
    initialized = 1;
    
    % Char types
    typemap.uchar   = 1;
    typemap.char    = 1;
    typemap.schar   = 1;
    
    % Integer types
    typemap.int8    = 1;
    typemap.int16   = 2;
    typemap.int32   = 4;
    typemap.short   = 2;
    typemap.int     = 4;
    typemap.long    = 4;
    
    typemap.uint8    = 1;
    typemap.uint16   = 2;
    typemap.uint32   = 4;
    typemap.ushort   = 2;
    typemap.uint     = 4;
    typemap.ulong    = 4;
    
    % Floating point types
    typemap.single   = 4;
    typemap.float32  = 4;
    typemap.float    = 4;
    typemap.double   = 8;
    typemap.float64  = 8;
end

s = typemap.(type);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?