writebin.m

来自「这是一个关于MATLAB的函数」· M 代码 · 共 47 行

M
47 行
字号
function dummy = writebin(mm,index,data)
%   Copyright 2002 The MathWorks, Inc.
%   $Revision: 1.1 $  $Date: 2002/05/15 21:08:01 $

error(nargchk(2,3,nargin));
if ~ishandle(mm),
    error('First Parameter must be a BITFIELD Handle.');
end

error('No WRITEBIN method for Bitfield objects');

if nargin==2,   
    data = index;
elseif nargin==3 & isempty(index)
    index = 1;
end

% convert strings/cell array into hexadecimal
if ischar(data),   % Data is a cell array of hexidecimal (value sized)
    try 
        data = bin2dec(data);
    catch
        error('DATA must contain valid binary characters ');        
    end
elseif iscellstr(data)
    try
        data = [bin2dec(data)];
    catch
        error('DATA must contain valid binary characters ');
    end
    if length(mm.size)==1
        data = reshape(data,1,mm.size);
    else
        data = reshape(data,mm.size);
    end
else
    error('DATA must be a binary string or a cell array of binary strings');
end

if nargin == 2,
    write_numerichex(mm,data);
else % index version - one value only!
    write_numerichex(mm,index,data);
end

% [EOF] writebin.m

⌨️ 快捷键说明

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