FFD Two-level Fractional Factorial Design CALL: [D,I] = ffd(n,I); [D,I] = ffd(n,p); D = design matrix size 2^(n-p) x n n = number of variables I = matrix of design generators. size p X q (default []) p = Number of generators FFD constructs a fractional factorial design for N variables in 2^(N-P) runs. The matrix I contains P generators that define the design, see SUDG. If I is empty a full factorial design is returned. In general, increase in the degree of fractionation lowers the resolution of the best fraction and increases confounding between effects of various orders. Examples I1 = sudg(15,11); D1 = ffd(15,I1); % Saturated Resolution III design. See also sudg
Column Label to Column Number | |
Column Number to Column Label. | |
Some Useful Design Generators | |
Get bit. | |
Difference and approximate derivative. | |
Display message and abort function. | |
True for character array (string). | |
Write formatted data to string. | |
Linear index from multiple subscripts. |
Cubic plot of responses |
001 function [D,I] = ffd(n,I) 002 %FFD Two-level Fractional Factorial Design 003 % 004 % CALL: [D,I] = ffd(n,I); 005 % [D,I] = ffd(n,p); 006 % 007 % D = design matrix size 2^(n-p) x n 008 % n = number of variables 009 % I = matrix of design generators. size p X q (default []) 010 % p = Number of generators 011 % 012 % FFD constructs a fractional factorial design for N variables in 013 % 2^(N-P) runs. The matrix I contains P generators that define the 014 % design, see SUDG. If I is empty a full factorial design is returned. 015 % In general, increase in the degree of fractionation lowers the 016 % resolution of the best fraction and increases confounding between 017 % effects of various orders. 018 % 019 % Examples 020 % I1 = sudg(15,11); 021 % D1 = ffd(15,I1); % Saturated Resolution III design. 022 % 023 % See also sudg 024 025 % Reference 026 % Box, G.E.P, Hunter, W.G. and Hunter, J.S. (1978) 027 % Statistics for experimenters, John Wiley & Sons, pp 410 028 029 % Tested on: Matlab 5.3 030 % History: 031 % By Per A. Brodtkorb 16.03.2001 032 033 error(nargchk(1,2,nargin)) 034 if nargin<2|isempty(I); I = zeros(0,1); end 035 if length(I) ==1, I = sudg(n,I); end 036 if ischar(I), I = cl2cnr(I); end 037 038 039 p = size(I,1); 040 nmp = n-p; 041 rows = 2.^(nmp); 042 x1 = (0:rows-1)'; 043 x2 = 1:nmp; %(nmp):-1:1; 044 045 % Construct a full factorial design for n-p variables 046 % in standard order. 047 D = bitget(x1(:,ones(1,nmp)),x2(ones(rows,1),:)); 048 049 if p>0, 050 II = abs(I); 051 if any(II(:)>n), 052 txt = sprintf('Integers of the matrix of generators must be less or equal to %.0f ',n) 053 error(txt) 054 end 055 056 [ix,iy] = find(nmp<II & II <=n); 057 if length(ix)==0, 058 ind = nmp:n; 059 elseif length(ix)==p & all(diff(sort(ix(:)))) 060 ind = I(sub2ind(size(I),ix,iy)); 061 [iz,iu] = sort(ix); 062 ind = ind(iu); 063 else 064 error('Something wrong with the matrix of generators, I') 065 end 066 D2 = D; 067 D2(find(D2==0))=-1; 068 D = [D zeros(rows,p)]; 069 for ix = 1:p, 070 k = find(0<II(ix,:) & II(ix,:)<= nmp); 071 if any(k), 072 sgn = prod(sign(I(ix,k)))*ind(ix); 073 D(:,abs(ind(ix))) = (prod(D2(:,II(ix,k)),2)*sgn>0); 074 else 075 error('Matrix of generators can not contain rows with only zeros') 076 end 077 end 078 end 079 if nargout>1, 080 I = cnr2cl(I); 081 end 082 return 083 084
Comments or corrections to the WAFO group