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?

댓글을 달려면 로그인하십시오.

추가 답변 (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