Using ALLCOMB for unknown number of vectors
12 views (last 30 days)
Show older comments
Hello There!
I have N number of vectors recorded into workspace. I need to perform combination among themselves by using allcomb. How could I introduce the vectors into the command (allcomb) in the form of B = ALLCOMB(A1,A2,A3,...,AN).
Thanks inadvance....
3 Comments
John D'Errico
on 18 Sep 2019
READ THE RESPONSE BY BRUNO. Learn how to use cell arrays instead of dynamically naming your variables. Numbered variables is a terrible programming style, that if you continue to follow it, will continuously lead you into problems, just as you are having now.
Answers (1)
Bruno Luong
on 18 Sep 2019
Create a CELL array, and get rid of the method of naming your variables with number 1,2,....
C = {A1, A2, A3, ..., AN}
B = allcomb(C{:});
14 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!