I am looking to find all the possible combinations of 2 values over a span. eg. For 24 hrs in a day, I need a variable to take either Val 1 or Val2. This generates 2^24 overall possible combinations of paths to take. How can I generate this Matrix ? I need this for some Brute force analysis. Let me know,
Thanks, Vinay

 採用された回答

Torsten
Torsten 2016 年 2 月 16 日
編集済み: Torsten 2016 年 2 月 16 日

0 投票

P = dec2bin(0:(2^24)-1)-'0';
P(P==0) = Val1;
P(P==1) = Val2;
Best wishes
Torsten.

3 件のコメント

Vinay Shekar
Vinay Shekar 2016 年 2 月 16 日
Thanks a lot!!
Vinay Shekar
Vinay Shekar 2016 年 2 月 16 日
Can this be used for 3 variables also..Val1,2 & 3?
Torsten
Torsten 2016 年 2 月 17 日

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索

質問済み:

2016 年 2 月 15 日

コメント済み:

2016 年 2 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by