www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@xregbdryroot/xregbdryroot.m

    function this = xregbdryroot( varargin )
%XREGBDRYROOT A root node in a boundary modeling tree of models.
%
%  R = XREGBDRYROOT(NAME, N, BoundaryData) is a boundary modeling tree root
%  node object with the given name, NAME, and number of stages, N.
%
%  A copy of the object will be put on the heap if and only if there are
%  input areguments.
%
%  R = XREGBDRYROOT(STRUCT) will make a boundary root using the given
%  structure as the object structure. Using this method will NOT result in
%  the object being put on the heap. This form is designed to support
%  LOADOBJ.
%
%  XREGBDRYROOT objects are child objects of XREGBDRYNODE.
%
%  See also: XREGBDRYNODE, MCTREE, BoundaryData

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

% If the first argument is an xregbdryroot, then return it
if nargin >= 1 && isa( varargin{1}, 'xregbdryroot' ),
    this = varargin{1};
    return
end

if nargin == 1 && isstruct( varargin{1} ),
    putOnHeap = false; % Don't put on heap for load constructors
    this = varargin{1};
    parent = this.xregbdrynode;
    this = mv_rmfield( this, 'xregbdrynode' );
else
    % Pnly put object on heap if there were input arguments
    putOnHeap = nargin >= 1;

    % Create parent object
    if nargin,
        parent = xregbdrynode( varargin{1} );
    else
        parent = xregbdrynode;
    end
    
    % Number of stages
    if nargin < 2,
        ns = 1;
    else
        ns = floor( varargin{2} );
        ns = max( ns, 1 );
        ns = min( ns, 2 );
    end
    
    if nargin < 3
        boundaryData = xregbdrydata(xregpointer);
    else
        boundaryData = varargin{3};
    end

    % Setup object structure
    this = struct( ...
        'Version', 5.0, ...
        'Best', [], ...
        'NumStages', ns, ...
        'InputFactors', [], ...
        'BoundaryData', boundaryData);
end
this = orderfields( this );
% Instantiate object
this = class( this, 'xregbdryroot', parent );

% Put object on heap, but only put if there were input arguments
if putOnHeap,
    this = info( xregpointer( this ) );
end