Using ALLCOMB for unknown number of vectors

12 ビュー (過去 30 日間)
osman
osman 2019 年 9 月 18 日
コメント済み: Jos (10584) 2019 年 9 月 19 日
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 件のコメント
osman
osman 2019 年 9 月 18 日
My variables are dynamic. the number of variables is continuously changing. I can not write them as you said. I have to define a set of variable like B = ALLCOMB(A1,A2,A3,...,AN). I do not know how to do this.
John D'Errico
John D'Errico 2019 年 9 月 18 日
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.

サインインしてコメントする。

回答 (1 件)

Bruno Luong
Bruno Luong 2019 年 9 月 18 日
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 件のコメント
osman
osman 2019 年 9 月 19 日
Thanks so much! I really appreciate about what you made me recognize.
Jos (10584)
Jos (10584) 2019 年 9 月 19 日
Thanks Bruno, for correcting me, and thereby helping osman :-)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by