Make a matrix of different combinations.
1 次查看(过去 30 天)
显示 更早的评论
Hello, all,
If we need to make different combinations, like the first three entries among {0,1,2} and the fourth entry is from {0,1,...,1000} how to make this matrix? There should be 3^3*1001 rows for that matrix.
0 个评论
回答(2 个)
Walter Roberson
2012-6-24
See the "odometer" construction I describe in http://www.mathworks.com/matlabcentral/answers/29662-generate-points-sorted-by-distance
Andrei Bobrov
2012-6-25
one way
[k1,k2,k3,k4] = ndgrid(0:2,0:2,0:2,0:1000);
out = [k1(:),k2(:),k3(:),k4(:)];
or
cmb = fullfact([3 3 3 1001]); % 'fullfact' from 'Statistics Toolbox'
d = 0:1000;
out = d(cmb);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulated Annealing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!