Suppose that I have this array:
a = [1,2,3,4,5];
The output should be something like this:
1,2,3,4,5
2,1,3,4,5
3,1,2,4,5
4,1,2,3,5
5,1,2,3,4
how Can I do this? This function should be valid for different lengths of a
.
Using combinatory:
b = [a.' flipud(nchoosek(a,numel(a)-1))];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With