How to create all range of given vector (possible permutations)?

3 ビュー (過去 30 日間)
Aravin
Aravin 2016 年 9 月 2 日
編集済み: Stephen23 2016 年 9 月 2 日
How to create all possible values of vector. For example, I have binary vector of length 2, then are possible four vectors.
[0 0; 1 1; 1 0; 0 1];
So what if I have binary vector of length 10, then there are 2^10 different vector. How may I generate all possible vectors. Specially, when my vector is not binary too. For example, if I have unint8 vector of length two, then there are 256^2. How may I do this ?

回答 (1 件)

Stephen23
Stephen23 2016 年 9 月 2 日
編集済み: Stephen23 2016 年 9 月 2 日
Use Jos' FEX submission permn:
>> permn([0,1],2)
ans =
0 0
0 1
1 0
1 1
>> permn([0,1,2],2)
ans =
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by