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

📄 subsasgn.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
字号:
function hFigure = subsasgn(hFigure, S, V)
% BVQXfigure::subsasgn  - set properties on objects
%
% FORMAT:       FigureObject.PropertyName = Value

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

% class check
if nargin > 2 && ...
    ~isa(hFigure, 'BVQXfigure')
    try
        hFigure = builtin('subsasgn', hFigure, S, V);
    catch
        rethrow(lasterror);
    end
    return;
end

% argument check
if isempty(S)
    error( ...
        'BVQXfigure:BadSubsAsgn', ...
        'S struct may not be empty.' ...
    );
end
slen  = length(S);
stype = S(1).type;
ssubs = S(1).subs;

% decide on kind of subscripting, first struct-like notation
switch stype, case {'.'}
    
    % check for subscript type
    if ~ischar(ssubs) || ...
        isempty(ssubs)
        error( ...
            'BVQXfigure:BadSubsAsgn', ...
            'Struct notation needs a non-empty char property.' ...
        );
    end
    
    % only works for singular object
    if numel(hFigure) ~= 1
        error( ...
            'BVQXfigure:InvalidObjectSize', ...
            'Struct notation only works on singular objects.' ...
        );
    end
    
    % make content linear
    ssubs = ssubs(:)';
    
    % set complete property
    if slen == 1
        
        % try setting value
        try
            set(hFigure.mhnd, ssubs, V);
        catch
            rethrow(lasterror);
        end
        
    % set sub value
    else
        
        % try getting, altering and re-setting value
        try
            cV = get(hFigure.mhnd, ssubs);
            cV = subsasgn(cV, S(2:end), V);
            set(hFigure.mhnd, ssubs, cV);
        catch
            rethrow(lasterror);
        end
    end
    
% indexing requested
case {'()'}
    
    % we need non-empty cell subscript
    if ~iscell(ssubs) || ...
        isempty(ssubs)
        error( ...
            'BVQXfigure:BadSubsRef', ...
            'Can''t index into BVQXfigure matrix.' ...
        );
    end
    
    % convert hFigure to struct
    sFigure = struct(hFigure);
    
    % try to retrieve subscripted matrix
    try
        subset   = subsref(sFigure, S(1));
    catch
        error( ...
            'BQVXfigure:BadSubsRef', ...
            'Invalid subscript (%s).', ...
            lasterr ...
        );
    end
    
    % no further subsasgn requested
    if slen == 1
        if ~strcmpi(class(V), 'bvqxinifile')
            error( ...
                'BVQXfigure:BadSubsAsgnValue', ...
                'Class mismatch error.' ...
            );
        end
        
        % try to assign new objects into matrix
        try
            sFigure = subsasgn(sFigure, S(1), struct(V));
            hFigure = class(sFigure, 'BVQXfigure');
        catch
            error( ...
                'BVQXfigure:BadSubsAsgnIndex', ...
                'Couldn''t assign partial object matrix (%s).', ...
                lasterr ...
            );
        end
        return;
    end
    
    if numel(subset) ~= 1
        error( ...
            'BVQXfigure:InvalidObjectSize', ...
            'Further subscripting only works for singular objects.' ...
        );
    end
    
    try
        subsasgn(class(subset, 'BVQXfigure'), S(2:end), V);
    catch
        error( ...
            'BVQXfigure:BadSubsAsgnSubs', ...
            'Error passing subsasgn to object (%s).', ...
            lasterr ...
        );
    end
    
otherwise
    error( ...
        'BVQXfigure:BadSubsAsgn', ...
        'Only struct notation allowed to set values.' ...
    );
end

⌨️ 快捷键说明

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