How can sort permutations.
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Triveni
le 1 Nov 2015
Réponse apportée : Andrei Bobrov
le 1 Nov 2015
Please help me to solve it
A=[30 30 30 30 30 30 60 60 60 60 60 60 60 60 30 30 30 30 30 30];
[c,b] = hist(A,unique(A));
N= length(A);
x = permn(b,N); %function permn
I have matrix A. i want to sort x. i need c(1,1) no of angle of 30. and c(1,2) no of angle of 60. means i need 12 nos of 30 and 8 nos of 60 in every permutations. How can i do it...please help me. Just like perms command works. but it's limited to 10. i need 20.
I also have another program but it's only works with 0 and 1.
A=[1 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1];
n2 = numel(A);
b2 = nnz(A);
M2 = 0:ones(1,n2)*pow2(n2-1:-1:0)';
z2 = rem(floor(M2(:)*pow2(1-n2:0)),2);
out = z2(sum(z2,2) == b2,:);
0 commentaires
Réponse acceptée
Andrei Bobrov
le 1 Nov 2015
A=[30 30 30 30 30 30 60 60 60 60 60 60 60 60 30 30 30 30 30 30];
A1 = A;
A = A1 > 30;
n2 = numel(A);
b2 = nnz(A);
M2 = 0:ones(1,n2)*pow2(n2-1:-1:0)';
z2 = rem(floor(M2(:)*pow2(1-n2:0)),2);
ii = z2(sum(z2,2) == b2,:);
aa = [30 60];
out = aa(ii + 1);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!