ALIAS Alias structure of a fractional design. CALL: str = alias(I0,n); str = string containing the alias structure. I0 = complete defining relation. n = maximum order of alias structure. Example I = sudg(6,2); % Design generator I0 = cdr(I); % Complete defining relation alias(I0) % The complete alias structure alias(I0,3) % Alias structure neglecting interactions larger than 3 See also cdr
Complete Defining Relation | |
Column Label to Column Number | |
Column Number to Column Label. | |
Concatenate arrays. | |
Create cell array. | |
Create cell array of strings from character array. | |
Deal inputs to outputs. | |
Difference and approximate derivative. | |
Display message and abort function. | |
True for numeric arrays. | |
Recursive string replacement. | |
Set exclusive-or. | |
Sort rows in ascending order. | |
Find possible matches for string. | |
Vertically concatenate strings. | |
Display warning message; disable or enable warning messages. |
001 function [I00,I11] = alias(I0,order) 002 %ALIAS Alias structure of a fractional design. 003 % 004 % CALL: str = alias(I0,n); 005 % 006 % str = string containing the alias structure. 007 % I0 = complete defining relation. 008 % n = maximum order of alias structure. 009 % 010 % Example 011 % I = sudg(6,2); % Design generator 012 % I0 = cdr(I); % Complete defining relation 013 % alias(I0) % The complete alias structure 014 % alias(I0,3) % Alias structure neglecting interactions larger than 3 015 % 016 % See also cdr 017 018 019 %Known Bugs: 1) Number of variables must be less than 51 020 % 2) n<inf produse 021 error(nargchk(1,2,nargin)) 022 if nargin<2|isempty(order),order = inf; else order = abs(order);end 023 if isempty(I0), 024 str = 'No alias structure'; 025 disp(str) 026 return 027 end 028 029 030 if isnumeric(I0) 031 k = max(I0(:)); % Number of variables. 032 I0 = cnr2cl(I0); 033 else 034 k = max(cl2cnr(I0(:))); % Number of variables. 035 end 036 p0 = size(I0,1); 037 038 p = log2(p0+1); % Number of generators. 039 if p~=round(p), % May be it is a design generator 040 warning('This is not a Complete Defining Relation') 041 I0 = cdr(I0) 042 p0 = size(I0,1); 043 p = log2(p0+1); % Number of generators. 044 end 045 046 n = 2^(k-p); % Number of aliases 047 048 % Make a list of all possible main effects and interaction effects 049 %------------------------------------------------------------------ 050 id = zeros(2^k-1,k); 051 iz = 0; 052 for ix = 1:k, 053 iz = iz+1; 054 id(iz,1) = ix; 055 iz0 = iz; 056 for iy = 1:iz0-1, 057 iz = iz+1; 058 id(iz,:) = id(iy,:); 059 ind = min(find(id(iy,:)==0)); 060 id(iz,ind) = ix; 061 end 062 end 063 % Make sure whitespace is at the end. 064 id = fliplr(sortrows(fliplr(cnr2cl(id)))); 065 066 if 0, % This is not needed 067 % Remove the defining relation effects from the effects list 068 for ix=1:p0 069 k1 = strmatch(I0(ix,:),id,'exact'); 070 if any(k1) 071 id(k1,:)=[]; 072 end 073 end 074 end 075 076 id = cellstr(id); 077 078 I0 = cellstr(I0); 079 I11 = cell(n,p0+1); 080 081 082 % Find all aliases 083 %------------------------------------------ 084 [I11{end,1:p0}] = deal(I0{:}); 085 I11{end,p0+1}= ' '; 086 wl = zeros(1,p0); % word length 087 for ix =1:n-1 088 I11(ix,1) = {id{ix}}; 089 for iy = 1:p0 090 %disp([ix,iy]) 091 tmp = setxor(id{ix},I0{iy}); 092 wl(iy) = length(tmp)-any(tmp=='-'); % Save the word length for later sorting. 093 I11(ix,iy+1) = {tmp}; 094 k1 = strmatch(tmp,id,'exact'); 095 if any(k1), % Remove found aliases from the effects list. 096 ind = ones(size(id)); 097 ind(k1) = 0; 098 id = id(logical(ind)); 099 end 100 end 101 % Sort by word length 102 [wl,ind]=sort(wl); 103 I11(ix,2:end) = I11(ix,ind+1); 104 k1 = find(wl>order); 105 if any(k1), % remove interactions of higher order than order. 106 [I11{ix,k1+1}]= deal(' '); 107 end 108 if length(id)<=ix, 109 warning('Something is wrong') 110 break, 111 end 112 end 113 114 tmp = cell(2,p0+1); 115 [tmp{2,1:p0}]=deal( ' + '); 116 tmp{2,p0+1} = ' '; 117 I00= []; 118 for ix = 1:n 119 [tmp{1,:}] = deal(I11{ix,:}); 120 % old call 121 %tmp1 = char(tmp)'; 122 123 % New call 124 tmp1 = cat(2,tmp{:}); 125 % Remove any multiple whitespaces. 126 tmp1 = rstrrep(tmp1(:).',' ', ' '); % rstrrep from string utility toolbox 127 k1 = find(tmp1 == '-'); 128 if any(k1), 129 tmp1(k1-2)='-'; % Change + to - 130 tmp1(k1)=''; % Remove old - signs 131 end 132 I00 = strvcat(I00,tmp1); 133 end 134 135 136 function str = rmwhite(str) 137 138 x = (str==' ') 139 dx = diff(x) 140 141 142 143
Comments or corrections to the WAFO group