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

📄 gluetostring.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function glued = gluetostring(textincells, linedelim, endterm)
% gluetostring  - glues a cell array of chars to one delimited char array
%
% FORMAT:         glued = gluetostring(textincells ,[linedelim,endterm])
%
% Input Fields:
%    textincells  cell array of char arrays to glue
%    linedelim    optional char array with glueing array
%                 defaults to system dependend CR/LF or LF
%    endterm      if given, do not remove end terminator
%
% if no linedelim is given, lines are limited system dependend
%
% See also splittocell.

% Version:  v0.5c
% Build:    6120415
% Date:     Dec-04 2006, 3:15 PM CET
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% enough/good arguments ?
if nargin < 1 || ...
   (~iscell(textincells) && ...
    ~ischar(textincells))
    error( ...
        'BVQXtools:BadArguments',...
        'Bad or too few arguments. Try ''help %s''.',...
        mfilename ...
    );
end

% make sure we have a cell array
if ischar(textincells)
    textincells = cellstr(textincells);
end

% what delimiter
if nargin < 2
    if ispc
        linedelim = char([13,10]);
    else
        linedelim = char(10);
    end
end

% how many items
ilen = numel(textincells);

% for few items ...
if ilen < 4096
    if any(size(textincells)) < 1
        glued = '';
        return;
    else
        glued = sprintf( ...
                ['%s' strrep(strrep(linedelim,'%','%%'),'\','\\')], ...
                textincells{:} ...
                );
    end

% many items ...
else
    tlen = min(256,floor(sqrt(ilen)));
    tvec = 1:tlen:ilen;
    tcnt = cell(1,length(tvec));
    tac  = 1;
    for tc = 1:tlen:ilen
        tcnt{tac} = gluetostring(textincells(tc:min(ilen,(tc+tlen-1))),linedelim);
        tac = tac + 1;
    end
    glued = gluetostring(tcnt,linedelim,1);
end

% end terminator
if (nargin < 3 || ...
    isempty(endterm)) && ...
   ~isempty(glued)
    glued((end+1-length(linedelim)):end) = [];
end

⌨️ 快捷键说明

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