I'm currently working on generating a comprehensive list of all possible combinations of multiple arrays. While I have experience in Matlab and understand loops and basic coding principles, I'm unsure of the most efficient method to compile these arrays into a matrix of combinations. Initially, I created a matrix of all potential combinations, but realized it would be time-consuming to update each entry if I decided to add a new component to one of the arrays. I attempted to use the push command to address this, as shown below:
matrix=[array1, array2, array3]
var newMeat= 'pastrami'
matrix[1].push(bread[1] + '-' + newMeat + ....)
Although using the push command from a user interface (UI) seemed messy. For instance, I have a base array:
bread=['rye', 'white', 'wheat']
I aim to create combinations for each bread type with other arrays like
meat = ['roast beef', 'ham', 'turkey']
condiments = ['mayo', 'mustard','ketchup']
This would result in:
combinations = ['rye-roast beef-mayo', 'white-roast beef-mayo', 'wheat-roast beef-mayo',
'rye-roast beef-mustard', 'white-roast beef-mustard', 'wheat-roast beef-mustard',
'rye-roast beef-ketchup', 'white-roast beef-ketchup', 'wheat-roast beef-ketchup']
and so forth. The columns would correspond to rye bread, white bread, and wheat bread respectively. Is there a specific term for this process I'm attempting? It should also accommodate additions to each array in the future. Appreciate any insights provided!