MATLAB: How to Permute the array with specific number matrix array I want to keep 1,2,6,7,9,10, they will not move I have this array b=[1,5,2,8,6,11,7,9,3,10]P=perms(b); HOw to use perms for 3,5,8,11 among 6 numbers above? Best Answer >> b = [1,5,2,8,6,11,7,9,3,10];>> idx = ~ismember(b,[1,2,6,7,9,10]);>> mat = repmat(b,factorial(nnz(idx)),1);>> mat(:,idx) = perms(b(idx))mat = 1 11 2 8 6 5 7 9 3 10 1 11 2 8 6 3 7 9 5 10 1 11 2 5 6 8 7 9 3 10 1 11 2 5 6 3 7 9 8 10 1 11 2 3 6 8 7 9 5 10 1 11 2 3 6 5 7 9 8 10 1 8 2 11 6 5 7 9 3 10 1 8 2 11 6 3 7 9 5 10 1 8 2 5 6 11 7 9 3 10 1 8 2 5 6 3 7 9 11 10 1 8 2 3 6 11 7 9 5 10 1 8 2 3 6 5 7 9 11 10 1 5 2 11 6 8 7 9 3 10 1 5 2 11 6 3 7 9 8 10 1 5 2 8 6 11 7 9 3 10 1 5 2 8 6 3 7 9 11 10 1 5 2 3 6 11 7 9 8 10 1 5 2 3 6 8 7 9 11 10 1 3 2 11 6 8 7 9 5 10 1 3 2 11 6 5 7 9 8 10 1 3 2 8 6 11 7 9 5 10 1 3 2 8 6 5 7 9 11 10 1 3 2 5 6 11 7 9 8 10 1 3 2 5 6 8 7 9 11 10 Related SolutionsMATLAB: How to creat two box plot in one graph use different data One way is to use a "grouping variable" as the second argument:a=[9 3 5 3 0 10 6 8 4 9 7 3 8 6 6 9 1 8 8 6 10];b=[10 7 5 6 8 6 4 7 8 8 9 7 10 7 6 6 7 2 8 10 8];ag = ones(size(a));bg = 2*ones(size(b));figureboxplot([a b]',[ag bg]')set(gca,'XTickLabel',{'a','b'}) MATLAB: Is it possible to extract the values with a vector of indices for each row without using the for statement from the matrix see sub2ind()A = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; % reference matrixb = [2; 1; 1; 3]; % index for each row that I want to extractidx = sub2ind(size(A), 1:size(A,1), b.');A(idx)Result>> A(idx)ans = 2 4 7 12 Related QuestionHelp running Matlab scriptMatrix multiplication using a for loopHow to get permutation of two halves of given numbers range 1 to n separately and then concatenate.How to modify a matrix to change the entries >=0 and multiply it by 5 AND to change the entries <0 and add 2 to those entriesHow to flip every 5th row and column in matrix
Best Answer