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