Creating matrix of unique combinations of variables
조회 수: 1 (최근 30일)
이전 댓글 표시
I need to create a matrix that lists out each combinations of variables in each row.
Assume that I have 5 variables a1, a2, a3, a4, a5 that all have 10 possible values of 0.1:0.1:1, what is an elegant way to list out the 10^5 rows of combinations?
Thank you so much!
댓글 수: 0
채택된 답변
Walter Roberson
2015년 10월 19일
nvals = 5;
[a{1:nvals}] = ndgrid(0.1:0.1:1);
Result = cell2mat(cellfun(@(C) C(:), a, 'Uniform', 0));
추가 답변 (1개)
Martin Schätz
2015년 10월 18일
Hi, it would be nice to have some code to work with included. But this is actually thing you would easily solve with MatLab help. Look at perms function. Input is your data and output is array of all possible combinations.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!