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

📄 convones.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function cfunc = convones(f, cnum)
% convones  - convoles a function with a number of consecutive ones
%
% FORMAT:       cfunc = convones(f, cnum)
%
% Input fields:
%
%       f           function to convolve
%       cnum        number of consecutive ones to use
%
% Output fields:
%
%       cfunc       ones-convolved function
%
% See also conv

% Version:  v0.6c
% Build:    7011010
% Date:     Jan-10 2007, 10:15 AM CET
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 2 || ...
   ~isa(f, 'double') || ...
    numel(f) ~= length(f) || ...
   ~isa(cnum, 'double') || ...
    numel(cnum) ~= 1 || ...
    isinf(cnum) || ...
    isnan(cnum) || ...
    cnum < 1 || ...
    cnum ~= fix(cnum)
    error( ...
        'BVQXtools:BadArgument', ...
        'Bad or missing first argument.' ...
    );
end

% special case: cnum == 1
if cnum == 1
    cfunc = f;
    return;
end

% get size and dim of f
fn = numel(f);
[fd{1:2}] = max(size(f));
f = f(:);

% produce output and intermediate vector
lf = fn + cnum - 1;
cfunc = zeros(lf, 1);
cimed = [f; zeros(cnum - 1, 1)];

% continue as long as cnum is not 0 !
cpos = 0;
mfac = fix(cnum / 2);
cfac = 1;
while cnum > 0
    if mod(cnum, 2)
        cfunc = cfunc + ...
            [zeros(cpos, 1); cimed(1:lf-cpos)];
        cpos = cpos + cfac;
    end
    if cfac > mfac
        break;
    end
    cimed = [cimed(1:lf-cfac) ; zeros(cfac, 1)] + ...
            [zeros(cfac, 1) ; cimed(1:lf-cfac)];
    cfac = cfac * 2;
    cnum = fix(cnum / 2);
end

% shift to f dim
if fd{2} > 1
    cfunc = shiftdim(cfunc, 1 - fd{2});
end

⌨️ 快捷键说明

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