www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@cset_grdlatt/designproperties.m
function p = designproperties(c,p,m) %DESIGNPROPERTIES properties for command-line % % p = designproperties(c,p) % Copyright 2007 The MathWorks, Inc. CLSID = mfilename('class'); [p,OK] = PersistentStore(p,CLSID); if ~OK p = iMakeProps(c,p,m); PersistentStore(p,CLSID); end function p = iMakeProps(c,p,m) p = designproperties(c.candidateset,p,m); p = addprop(p,'NumberOfPoints',... @iGetNumberOfPoints,... '',... 'int',[0 Inf],... 'Number of points'); p = addprop(p,'LatticeInputs',... @iGetLatticeInputs, @iSetLatticeInputs,... '','',... 'Logical array indicating lattice inputs'); p = addprop(p,'LatticeSize',... @iGetRuns, @iSetRuns,... 'int',[0 Inf],... 'Number of lattice points'); p = addprop(p,'PrimeGenerators',... @iGetGenerators, @iSetGenerators,... '','',... 'Prime number generators for lattice for each lattice input'); p = addprop(p,'Levels',... @iGetLevels,... @iSetLevels,... 'cell','',... 'Cell array of levels for each grid input'); p = addprop(p,'NumberOfLevels',... @iGetNumberLevels,... @iSetNumberLevels,... '','',... 'Number of levels for each grid input'); function v = iGetLatticeInputs(c,m) v = get(c,'latticedims'); v = ismember(1:nfactors(c),v); function c = iSetLatticeInputs(c,v,m) if islogical(v) && numel(v)==nfactors(c) && sum(v)>1 v = find(v); c = set(c,'latticedims',v); else error(message('mbc:doe:InvalidValue25', nfactors( c ))); end function v = iGetGenerators(c,m) v = get(c,'g'); function c = iSetGenerators(c,v,m) n = sum(iGetLatticeInputs(c)); if numel(v)==n && all(isprime(v)) c = set(c,'g',v); else error(message('mbc:doe:InvalidValue26', n)); end function v = iGetRuns(c,m) v = get(c,'N'); function c = iSetRuns(c,v,m) c = set(c,'N',v); function v = iGetLevels(c,m) v = get(c,'levels'); for i=1:length(v) v{i} = invcode(m,v{i}(:),i)'; end function c = iSetLevels(c,v,m) n = nfactors(c)-sum(iGetLatticeInputs(c)); if numel(v)==n gd= get(c,'griddims'); for i=1:length(v) if isnumeric( v{i}) v{i} = code(m,v{i}(:),gd(i))'; else error(message('mbc:doe:InvalidValue27')) end end c = set(c,'levels',v); else error(message('mbc:doe:InvalidValue28', n)) end function v = iGetNumberLevels(c,m) v = cellfun(@numel,get(c,'levels')); v = v(:)'; function c = iSetNumberLevels(c,v,m) n = nfactors(c)-sum(iGetLatticeInputs(c)); if numel(v)==n lims = limits(c); levels= cell(size(v)); gd= get(c,'griddims'); for i=1:length(v) x = v(i); if isnumeric(x) && all(x==fix(x)) && x>0 levels{i} = linspace(lims(gd(i),1),lims(gd(i),2),x); else error(message('mbc:doe:InvalidValue29')) end end c = set(c,'levels',levels(:)); else error(message('mbc:doe:InvalidValue30', n)) end function v = iGetNumberOfPoints(c,m) v = prod( cellfun(@numel,get(c,'levels')) ) * iGetRuns(c,m);