ffacdes1.m

来自「PLS_Toolbox是用于故障检测与诊断方面的matlab工具箱」· M 代码 · 共 61 行

M
61
字号
function desgn = ffacdes1(k,p)
%FFACDES1 2^(k-p) fractional factorial design of experiments.
%  Input (k) is the total number of factors in the design, and
%  (p) is the number of confounded factors (default = 1);
%  p < k. (desgn) is a matrix of the experimental design.
%
%I/O: desgn = ffacdes1(k,p);
%
%See also: FACTDES

%Copyright Eigenvector Research, Inc. 1996-2000
%nbg

if nargin<2
  p    = 1;
end
if (p<0 | k<0)
  error('Error - inputs must be > 0')
end
if (p>(k+1)/2)
  error('Error - only designs with k-p+1>=p allowed')
end
if p >= k
  error('Error - p must be less than k')
end

desgn  = factdes(k-p);
nexp   = size(desgn,1);

if p ~= 0
  if p == 1
    %confound with all k-p
	  y    = mncn(desgn)*2;
	  conf = y(:,1);
	  for ii = 2:k-p
      conf = conf.*y(:,ii);
	  end
	  conf = scale(conf,-1)/2;
	  desgn = [desgn,conf];
  else
    %confound with k-p-1
	  [z,ii]= sort(sum(desgn')');
	  jj    = find(z==k-p-1);
	  z     = desgn(ii,:);
	  ii    = jj(1);
	  for jj = 1:p
	    kk  = find(z(ii,:));
      y   = mncn(desgn(:,kk))*2;
	    conf= y(:,1);
	    for ij = 2:length(kk)
	      conf = conf.*y(:,ij);
	    end
	    conf  = scale(conf,-1)/2;
	    desgn = [desgn,conf];
	    ii    = ii + 1;
	  end  
  end
end


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?