www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@xregdesign/nfactors.m

    function n=nfactors(des,n)
%NFACTORS Number of factors in experiment
%
%  N=NFACTORS(D) returns the number of factors in the experimental design
%  matrix.

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


if nargin>1
   % set number of factors and check other arguments
   if n~=des.nfactors
      des.design = zeros(0, n);
      des.designindex = [];
      des.designpointflags = uint8([]);
      des.npoints = 0;
      des.nfactors = n;
      % sort out candidate space parameters
      des = fixcandspace(des);
      % destroy the constraints
      des.constraints = [];
   end
   n = des;
else
   n = des.nfactors;
end