⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asciiwrite.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function asciiwrite(filename, filecont, append, linedelim)
% asciiwrite  - writes a textfile from a char array to file
%
% FORMAT:       asciiwrite(filename, filecont [, append, linedelim])
%
% Input Fields:
%       filename    name to a file, preferably absolute path
%       filecont    char array to write
%       append      if true, content will be appended to file
%       linedelim   optional char array with line delimiter
%
% Note: if no linedelim is given, lines are limited system dependend
%
% See also asciiread, binwrite.

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

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

% options
if nargin < 3 || ...
    isempty(append) || ...
   ~append(1)
    omode = 'w';
else
    omode = 'a';
end
if nargin < 4 || ...
   ~ischar(linedelim)
    if ispc
        linedelim = char([13, 10]);
    else
        linedelim = char(10);
    end
end

% standard check on filename
if ispc
    filename = strrep(filename, '/', filesep);
else
    filename = strrep(filename, '\', filesep);
end

% get file pointer
ofp = fopen(filename, omode);
if ofp < 1
    error( ...
        'BVQXtools:FileNotWritable', ...
        'Couldn''t write to file ''%s''.', ...
        filename ...
    );
end
frewind(ofp);

% some more sanity checks on content
if iscell(filecont)
    filecont = char(filecont);
end

% make a 2-D char array a cell -> glue with linedelim
if size(filecont, 1) > 1
    filecont = gluetostring(cellstr(filecont), linedelim);
end

% write output
fwrite(ofp, filecont, 'uchar');
fclose(ofp);

⌨️ 快捷键说明

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