binread.m

来自「toolbox of BVQX, This is the access betw」· M 代码 · 共 56 行

M
56
字号
function bincont = binread(filename)
% binread  - reads a binary into one uint8 array
%
% FORMAT:       bincont = binread(filename)
%
% Input fields:
%
%       filename    name to a file, preferably absolute path
%
% Output fields:
%
%       bincont     1xN uint8 array
%
% See also asciiread, binwrite

% Version:  v0.7b
% Build:    7083014
% Date:     Aug-30 2007, 2:52 PM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% enough arguments ?
if nargin < 1 || ...
   ~ischar(filename) || ...
    isempty(filename)
    error( ...
        'BVQXtools:BadArgument',...
        'Bad or missing argument. Try ''help %s''.',...
        mfilename ...
    );
end

% file exist check
filename = filename(:)';
if exist(filename, 'file') ~= 2
    error( ...
        'BVQXtools:FileNotFound',...
        'File not found: %s',...
        filename(1:min(length(filename), 80)) ...
    );
end

% open file check
fp = fopen(filename, 'r');
if fp < 1
    error( ...
        'BVQXtools:FileNotReadable',...
        'File not readable: %s',...
        filename ...
    );
end

% read file contents
bincont = fread(fp, [1, Inf], '*uint8');
fclose(fp);

⌨️ 快捷键说明

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