Combinations of variables and step sizing for creation of DOE
7 ビュー (過去 30 日間)
古いコメントを表示
I'm using matlab to create .txt files containing variables for another program.
I'm trying to create a Design Of Experiments.
An example is, I have 3 variables,v1=5,v2=15 and v3=100
Now each variable also has a step size, v1s=1, v2s=5, v3s=10
and each variable steps by different amounts, so v1a=3,v2a=4,v3a=5
So now I have 3*4*5=60 possible different combinations.
so combination no: 1= 5,15,100 2= 6,15,100 3= 7,15,100 4= 5,20,100 5= 5,25,100 etc....
I'm trying to think of a way that can create all this on the fly for any amount of variables and step sizes but really coming unstuck here.
If anyone has some help it would be greatly appreciated.
Thanks.
0 件のコメント
採用された回答
Walter Roberson
2012 年 1 月 25 日
I do not understand about "steps by different amounts" as distinct from "step size" ?
It is not clear from what you posted that there are upper bounds on your variables.
If there are upper bounds on the variables, then for each variable construct the list of valid values and toss it in to a cell array entry, such as
varvals{4} = v1 : v1s : v1end;
When you have them all constructed, then
[valgrids{1:length(varvals)}] = ndgrid(varvals{:});
1 件のコメント
Walter Roberson
2012 年 1 月 25 日
Once you have done the above two steps,
tt = cellfun(@(M) reshape(M,[],1), valgrids,'Uniform',0);
combos = horzcat(tt{:}) .';
その他の回答 (2 件)
Tom Lane
2012 年 1 月 25 日
Do you have the Statistics Toolbox available? It seems like what you want is a full factorial design, but with the variable levels chosen from a set other than {1,2,...,k}. Here's an example creating a two-variable design with every combination of {10,20} for the first variable and {100,200,300} for the second.
>> s1 = [10 20];
>> s2 = [100 200 300];
>> x = fullfact([2 3])
x =
1 1
2 1
1 2
2 2
1 3
2 3
>> x(:,1) = s1(x(:,1));
>> x(:,2) = s2(x(:,2))
x =
10 100
20 100
10 200
20 200
10 300
20 300
This is similar to Walter's ndgrid idea, but for three variables it gives a three-column matrix instead of three separate MATLAB variables.
1 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!