Given n input vectors x1, x2, …, xn, generate a p*n matrix y whose rows contain all element-wise combinations of the vectors x1, x2, …, xn, where p = numel(x1)*numel(x2)*…* numel(xn). The rows of y are organized in an "increasing" ordering; see examples below.
y = ['ac' 'ad' 'ae' 'bc' 'bd' 'be']
y = [0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1]
You may assume that all inputs are valid vectors whose lengths are at least 1.
Note: The Statistics and Machine Learning toolbox provides two useful functions for full factorial design, namely ff2n (for binary case) and fullfact (for general cases). However, they do not directly accomplish the task in Example 1. The purpose of this problem is to create a toolbox independent function to achieve our goal. Have fun!
It would be better if the test suite did not rely on a particular ordering of the rows. You could use isempty(setxor(myfullfact(...), y_correct, 'rows')) instead of isequal(...)
Thanks for your suggestion. But I prefer an "increasing" ordering of the rows because that could be more useful in some applications. I have made it clear in the problem description that ordering is required.
Find common elements in matrix rows
812 Solvers
749 Solvers
65 Solvers
Construct an index vector from two input vectors in vectorized fashion
126 Solvers
401 Solvers