フィルターのクリア

Full Factorial Design of Experiments

32 ビュー (過去 30 日間)
mbyrl
mbyrl 2021 年 4 月 30 日
コメント済み: dpb 2021 年 5 月 14 日
Hello together,
i am about to write a code that should produce me a txt file with a full factorial combination of the input of vectors. The vectors could have a different length. I know about the matlab function fullfact([,]) but since I will use decimal numbers i needed a differen solution.
I tested the code and it seems to work. But do I make a mistake, that I may have not seen yet? The vectors that i defined in this skript are just for example. Later on I will use a input and the vectors will result in much bigger ones.
clc
clear
pyrz = [1, 2];
pyrx = [1, 2, 3];
pyra = [1, 2];
%I need to know the final count of columns in the resulting matrix
Avert=length(pyrz)*length(pyrx)*length(pyra);
if sum (pyrx) == 0
pyrx = zeros(1, Avert);
elseif sum (pyrx) ~= 0
count = Avert/length(pyrx);
pyrx = repmat(pyrx,1,count);
end
count = Avert/length(pyrz);
pyrz = repmat(pyrz,1,count);
pyrz = sort(pyrz);
count = Avert/length(pyra);
pyra = repmat(pyra,1,count);
pyra = sort(pyra,'descend');

採用された回答

dpb
dpb 2021 年 4 月 30 日
編集済み: dpb 2021 年 4 月 30 日
"I know about the matlab function fullfact([,]) but since I will use decimal numbers i needed a differen solution."
There's no reason still to not use fullfact; the levels [1:Nl] are simply placeholders for the actual levels for each factor, not the experimental levels themselves.
If you want to write an array/file that contains the actual levels themselves, just use a lookup table of the level into the values you define for each level. Nothing more is needed.
Small example for brevity; principle holds in general no matter the number of factors and levels...
>> ff=fullfact([3,2]) % design matrix for 3x2 full factorial
ff =
1 1
2 1
3 1
1 2
2 2
3 2
>>
>> LVLS=[4.3*[-1:1];[pi*[-1 1] nan]].' % array of Levels by column
LVLS =
-4.3000 -3.1416
0 3.1416
4.3000 NaN
>>
Now build the array of experiment levels
>>FF=cell2mat(arrayfun(@(r)[LVLS(ff(r,1),1) LVLS(ff(r,2),2)],1:size(ff,1),'UniformOutput',false).')
FF =
-4.3000 -3.1416
0 -3.1416
4.3000 -3.1416
-4.3000 3.1416
0 3.1416
4.3000 3.1416
>>
You could, of course, keep separate vector arrays for each factor or a cell array, I used an array with a NaN element for the missing levels to avoid the cell array route as it will never be referenced so it's just a placeholder to make a rectangular array.
  3 件のコメント
Sema Karakus
Sema Karakus 2021 年 5 月 14 日
Is there any way to implement restrictions for some of the factors?
dpb
dpb 2021 年 5 月 14 日
What kind of restrictions?

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by