www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cgdivexpr/set.m

    function varargout = set(varargin)
%SET Standard set method
%
%	SET(d) returns list of properties which can be set.
%	d = SET(d,'property',value,....) returns the object with properties
%	reset to the values given.

%  Copyright 2000-2004 The MathWorks, Inc. and Ford Global Technologies, Inc.



if nargin == 1 
    varargout{1} = i_ShowFields; 
else
    
    div_object = varargin{1};
    
    if nargin < 3
        error(message('mbc:cgdivexpr:InvalidArgument5'));
    end
    
    for i = 2:2:nargin
        
        property = varargin{i};
        new_value = varargin{i+1};
        
        if ~ischar(property)
            error(message('mbc:cgdivexpr:InvalidArgument6'));
        end
        
        switch lower(property)
            case 'top'
                if isa(new_value, 'xregpointer')
                    old_inputs = getinputs(div_object);                  
                    if div_object.NBottom>0
                        div_object = setinputs(div_object, [new_value(:)', old_inputs(div_object.NTop+1:end)]);
                    else
                        div_object = setinputs(div_object, new_value(:)');
                    end
                    div_object.NTop = length(new_value);
                else
                    error(message('mbc:cgdivexpr:InvalidPropertyValue'));
                end
            case 'bottom'
                if isa(new_value, 'xregpointer')
                    old_inputs = getinputs(div_object);                  
                    if div_object.NTop>0
                        div_object = setinputs(div_object, [old_inputs(1:div_object.NTop), new_value(:)']);
                    else
                        div_object = setinputs(div_object, new_value(:)');
                    end
                    div_object.NBottom = length(new_value);
                else
                    error(message('mbc:cgdivexpr:InvalidPropertyValue1'));
                end                

            otherwise
                error(message('mbc:cgdivexpr:InvalidPropertyName')); 
        end
    end
    
    if nargout > 0
        varargout{1} = div_object;
    elseif ~isempty(inputname(1))
        assignin('caller' , inputname(1) , div_object);
    end
    
end

function out = i_ShowFields
%Simply returns a structure, the fieldnames of which are the set-able
%fields of the object, and the fields contain more details.
out.top = 'xregpointer(s) to cgexpr objects';
out.bottom = 'xregpointer(s) to cgexpr objects';