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

📄 multiset.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function multiset(handles,varargin)
% multiset  - set properties for multiple handles
%
% FORMAT:       multiset(handles, property, values, ...)
%       OR      multiset(handles, propstruct)
%
% Input fields:
%
%       handles     Nx1 double array with object handles
%       property    string naming the property to set
%       values      Nx1 cell array with values to set
%       propstruct  Nx1 struct array with properties/values
%
% See also get, subget, set.

% Version:  v0.6e
% Build:    7041710
% Date:     Apr-17 2007, 10:02 AM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 2
    error( ...
        'BVQXtools:TooFewArguments', ...
        'Too few arguments. Try ''help %s''.', ...
        mfilename ...
    );
end
if nargin == 2 && ...
   ~isstruct(varargin{1})
    error( ...
        'BVQXtools:BadArgument', ...
        'No properties/values specified.' ...
    );
end
if ~isa(handles, 'double')
    error( ...
        'BVQXtools:BadArgument', ...
        'Wrong input type for handles.' ...
    );
end

% return on no handles
if isempty(handles)
    return;
end

% get number of handles
nh = numel(handles);

% check further for struct
if isstruct(varargin{1})
    ps = varargin{1};
    ns = numel(ps);
    if ns < nh && ...
        ns ~= 1
        error( ...
            'BVQXtools:BadArgument', ...
            'Not enough property values specified.' ...
        );
    end
    if ns == 1 && ...
        nh > 1
        ps(1:nh) = ps;
    end
    pf = fieldnames(ps);
    nf = length(pf);
    for fc = 1:nf
        try
            multiset(handles,pf{fc},{ps(:).(pf{fc})}');
        catch
            warning( ...
                'BVQXtools:InvalidProperty', ...
                'Couldn''t set property ''%s'' (%s)', ...
                pf{fc}, lasterr ...
            );
        end
    end
else
    for vac = 1:2:(nargin-1)
        if ~isrealvarname(varargin{vac})
            error( ...
                'BVQXtools:InvalidProperty', ...
                'Invalid property name given.' ...
            );
        end
        if ~iscell(varargin{vac+1})
            error( ...
                'BVQXtools:InvalidPropertyValue', ...
                'Invalid property value(s) given.' ...
            );
        end
        pn = varargin{vac};
        pv = varargin{vac+1};
        nv = numel(pv);
        if nv < nh && ...
            nv ~= 1
            error( ...
                'BVQXtools:BadArgument', ...
                'Not enough property values specified.' ...
            );
        end
        if nv == 1 && ...
            nh > 1
            pv = pv(ones(1,nh));
        end
        for hc = 1:nh
            try
                set(handles(hc),pn,pv{hc});
            catch
                error( ...
                    'BVQXtools:InvalidProperty', ...
                    'Error setting property. (%s)', ...
                    lasterr ...
                );
            end
        end
    end
end

⌨️ 快捷键说明

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