how to make a matrix only showing Permutation without order ?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
iam currently on projekt calculation every 3 Dart Single Kombination possible but without giving me the same number in a differnt order.
Code
c=[1:20 25]
Single1=c
Single2=Single1;
Single3=Single1;
Singlkomb = fliplr(combvec(Single1,Single2,Single3)')
the combination fliplr(combvec(Single1,Single2,Single3)') brings me all the combination e.g 1 2 1, 2 1 1 and 1 1 2 but i only want that the same numbers appears one time in the matrix. I want to find a method that shows me permutation without order.
Thx
0 Commenti
Risposta accettata
Torsten
il 28 Ott 2022
Modificato: Torsten
il 28 Ott 2022
You mean
nchoosek([1:20,25],3)
nchoosek(21,3)
not
21^3
?
Più risposte (1)
Bruno Luong
il 29 Ott 2022
This is called combination with repetition
You don't need to generate the permutation and filter out which can take much larger amount of memory
a=[1:20,25]
k=3
c=repcomb(a, k)
%% return combination of k elements of array a with repetition
function c = repcomb(a, k)
n=length(a);
q=n+k-1;
j=nchoosek(1:q,k)-(0:k-1);
c=a(j);
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Multirate Signal Processing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!