Creating matrix of unique combinations of variables
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Brian
am 18 Okt. 2015
Kommentiert: Brian
am 19 Okt. 2015
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 19 Okt. 2015
nvals = 5;
[a{1:nvals}] = ndgrid(0.1:0.1:1);
Result = cell2mat(cellfun(@(C) C(:), a, 'Uniform', 0));
Weitere Antworten (1)
Martin Schätz
am 18 Okt. 2015
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 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!