probability - Displaying only intersections between two sets of permutations in MatLab -


being supplied 2 strings, 'goosegun' , 'goslingnun', find every permutation of pick 3 of each string, display only intersections between two. doing without using intersect(comboperm1,comboperm2,'rows'), want know how use it. guess main problem figuring out how display text.

for variables use in code, here's how they're found.

r = 3; numperms = factorial(r);  elements1 = 'goosegun'; n1 = numel(elements1); numcombos1 = factorial(n1) / (factorial(n1-r)*factorial(r)); lettercombos1 = nchoosek(elements1,r);  elements2 = 'goslingnun'; n2 = numel(elements2); numcombos2 = factorial(n2) / (factorial(n2-r)*factorial(r)); lettercombos2 = nchoosek(elements2,r);  counter = -1; 

here code works (i think).

% goes through each combination = 1 : numcombos1     comboperm1 = perms(lettercombos1(i,:));      % goes through each permutation of combination     j = 1 : numperms         k = 1 : numcombos2             comboperm2 = perms(lettercombos2(k,:));              p = 1 : numperms                 if (comboperm1(j,:) == comboperm2(p,:))                     counter = counter + 1;                  if (mod(counter,numperms) == 0)                     fprintf('\n\t');                 end                  fprintf('%s ',comboperm2(p,:));                 end             end          end     end end 

here code i'm trying use intersect in.

for = 1 : numcombos1     comboperm1 = perms(lettercombos1(i,:));     j = 1 : numperms         k = 1 : numcombos2                 comboperm2 = perms(lettercombos2(k,:));                         p = 1 : numperms                 = intersect(comboperm1,comboperm2,'rows');                  if (exist(a, 'var') == 0)                     fprintf('%s ',a);                 end                     end         end     end end 

hope explained myself because first question on site. help.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -