binwrite.m
来自「toolbox of BVQX, This is the access betw」· M 代码 · 共 63 行
M
63 行
function binwrite(filename,content)
% binwrite - writes a binary stream from a char/uint8 array to file
%
% FORMAT: binwrite(filename,content)
%
% Input Fields:
% filename name to a file, preferably absolute path
% content char/uint8 array to write
%
% See also asciiwrite
% 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 < 2
error( ...
'BVQXtools:TooFewArguments', ...
'Too few arguments. Try ''help %s''.', ...
mfilename ...
);
end
% argument checks
if ~ischar(filename) || ...
(~ischar(content) && ...
~isa(content, 'uint8')) || ...
isempty(filename)
error( ...
'BVQXtools:BadArgument', ...
'Bad arguments in call.' ...
);
end
% filename mangling check
if ispc
filename = strrep(filename, '/', filesep);
else
filename = strrep(filename, '\', filesep);
end
% open file and check for handle
ofp = fopen(filename, 'w');
if ofp < 1
error( ...
'BVQXtools:FileNotWritable', ...
'Couldn''t write to file: %s.', ...
filename ...
);
end
frewind(ofp);
% rewind file, write content, and close file
if ischar(content)
fwrite(ofp, content, 'uchar');
else
fwrite(ofp, content, 'uint8');
end
fclose(ofp);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?