📄 binwrite.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -