www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@testplan/CreateDesign.m

    function D = CreateDesign(T,varargin)
%CREATEDESIGN create design object for test plan
%
% D = CreateDesign(Testplan);
% D = CreateDesign(Testplan,Level)
% D = CreateDesign(Testplan,Level,prop1,value1,...);
%   The property value pairs are properties of mbcdoe.design. Design Type
%   can be specified at creation.
%   Level:     Test plan level. By default the level is the outer level
%              (i.e. Level 1 for One-stage, Level 2 for Two-stage)
%
%Examples
% Create a space-filling design for a test plan TP:
% 
%    sfDesign = CreateDesign(TP, ...
%     'Type', 'Latin Hypercube Sampling',...
%     'Name', 'Space Filling');
% 
% Create a local level design for the two-stage test plan TP:
% 
%    localDesign = CreateDesign(TP,1,'Type','Latin Hypercube Sampling');
% 
% Create a global level design for the two-stage test plan TP:
% 
%    globalDesign = CreateDesign(TP,2, 'Type', 'Latin Hypercube Sampling');
% 
% See also mbcmodel.model.CreateDesign, mbcmodel.modelinput.CreateDesign,
% mbcdoe.design

%  Copyright 2007 The MathWorks, Inc.

dd = designdev(T.Object);
if nargin<2 || ~isnumeric(varargin{1})
    Level = length(dd);
elseif isnumeric(varargin{1})
    Level = varargin{1};
    varargin(1) = [];
end

dtree = dd(Level).DesignTree;
% use root design
des = dtree.designs{1};
% get default design type.
DefaultType = mbcdoe.design.DefaultType(nfactors(des));
D = mbcdoe.design(des,'Type',DefaultType,varargin{:});