Dynamic matrix columns combinations
Hello,
I would like to find all possible combinations of a matrix columns, with each column contribute a value, in each itteration of a loop. The matrix size changes in each itteration. For example:
A = [1 2 3
4 5 6
7 8 9].
should produce:
1 2 3
1 2 6
1 5 3 etc.
but should not produce:
1 4 2 for example.
My problems:
When insert the matrix to combvec function nothing happens. The function accept vectors – and since I do it with different matrix size in each Itteration of a loop I can’t write it manually.
ndgrid also requires vectors – and since I need to choose a combination index in other variable – I’m not clear how this happens.
I don’t have combination function in my Matlab version.
Is there a way to define vectors dynamically in a loop? any idea on to how overcome this? Do I need to write a combination function myself?Hello,
I would like to find all possible combinations of a matrix columns, with each column contribute a value, in each itteration of a loop. The matrix size changes in each itteration. For example:
A = [1 2 3
4 5 6
7 8 9].
should produce:
1 2 3
1 2 6
1 5 3 etc.
but should not produce:
1 4 2 for example.
My problems:
When insert the matrix to combvec function nothing happens. The function accept vectors – and since I do it with different matrix size in each Itteration of a loop I can’t write it manually.
ndgrid also requires vectors – and since I need to choose a combination index in other variable – I’m not clear how this happens.
I don’t have combination function in my Matlab version.
Is there a way to define vectors dynamically in a loop? any idea on to how overcome this? Do I need to write a combination function myself? Hello,
I would like to find all possible combinations of a matrix columns, with each column contribute a value, in each itteration of a loop. The matrix size changes in each itteration. For example:
A = [1 2 3
4 5 6
7 8 9].
should produce:
1 2 3
1 2 6
1 5 3 etc.
but should not produce:
1 4 2 for example.
My problems:
When insert the matrix to combvec function nothing happens. The function accept vectors – and since I do it with different matrix size in each Itteration of a loop I can’t write it manually.
ndgrid also requires vectors – and since I need to choose a combination index in other variable – I’m not clear how this happens.
I don’t have combination function in my Matlab version.
Is there a way to define vectors dynamically in a loop? any idea on to how overcome this? Do I need to write a combination function myself? combination MATLAB Answers — New Questions