وجدت هذا البرنامج فاحببت مشاركتكم به، البرنامج عبارة عن ملف مصدري مكتوب بالماتلاب لايجاد التباديل والتوافيق مع او بدون التكرار لمجموعة من العناصر.
يمكن تحميله من هنا.
COMBINATOR will return one of 4 different samplings on the set 1:N, taken K at a time. These samplings are given as follows:
PERMUTATIONS WITH REPETITION/REPLACEMENT
COMBINATOR(N,K,'p','r') -- N >= 1, K >= 0
PERMUTATIONS WITHOUT REPETITION/REPLACEMENT
COMBINATOR(N,K,'p') -- N >= 1, N >= K >= 0
COMBINATIONS WITH REPETITION/REPLACEMENT
COMBINATOR(N,K,'c','r') -- N >= 1, K >= 0
COMBINATIONS WITHOUT REPETITION/REPLACEMENT
COMBINATOR(N,K,'c') -- N >= 1, N >= K >= 0
Example:
combinator(4,2,'p','r') % Permutations with repetition
combinator(4,2,'p') % Permutations without repetition
combinator(4,2,'c','r') % Combinations with repetition
combinator(4,2,'c') % Combinations without repetition
ans =
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4
4 1
4 2
4 3
4 4
ans =
1 2
1 3
1 4
2 1
2 3
2 4
3 1
3 2
3 4
4 1
4 2
4 3
ans =
1 1
1 2
1 3
1 4
2 2
2 3
2 4
3 3
3 4
4 4
ans =
1 2
1 3
1 4
2 3
2 4
3 4
Example 2:
% a = ['a' 'b' 'c' ];
b = comb(length(a),2,'p');
b = a(b)
b = comb(length(a),2,'p','r');
b = a(b)
b = comb(length(a),2,'c');
b = a(b)
b = comb(length(a),2,'c','r');
b = a(b):happy:
بالتوفيق