Create Permutation in Matlab.

조회 수: 2 (최근 30일)
Prasanna Rajbhandari
Prasanna Rajbhandari 2015년 7월 28일
댓글: Prasanna Rajbhandari 2015년 7월 29일
We are trying to create a permutation with 1, 0, and -1. We want all the possible combinations. We have five different times. An example is:
t1-1 1 1 -1 -1
t2-1 0 1 -1 -1
t3-1 1 1 -1 -1
t4-1 1 0 -1 0
t5-0 1 0 0 1
These are some of the possible combinations. We want all of the possible combinations. But, we can't think of a way to get this. Can someone help us with this?

채택된 답변

Kelly Kearney
Kelly Kearney 2015년 7월 28일
a = cell(5,1);
[a{:}] = ndgrid([-1 0 1]);
a = cat(6, a{:});
a = reshape(a, [], 5);
  댓글 수: 1
Prasanna Rajbhandari
Prasanna Rajbhandari 2015년 7월 29일
Thank You so much for the help.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by