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

 Akzeptierte Antwort

Torsten
Torsten am 16 Feb. 2016
Bearbeitet: Torsten am 16 Feb. 2016

0 Stimmen

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

3 Kommentare

Vinay Shekar
Vinay Shekar am 16 Feb. 2016
Thanks a lot!!
Vinay Shekar
Vinay Shekar am 16 Feb. 2016
Can this be used for 3 variables also..Val1,2 & 3?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 15 Feb. 2016

Kommentiert:

am 17 Feb. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by