MATLAB: How to construct a matrix M1 with size of (2k − 2) × 1. M1 contains (k − 1) ones and (k − 1) zeros. For example, M1 = [1 1 1 0 0 0]T for k = 4. We obtain all possible permutations of M1, denoting Mi , i = 2, . . . ,N, where N = (2k−2)! (k−1)!(k−1)!

combination of sharing matrix and image encryption for lossless (kn)-secret image sharing

How to construct a matrix M1 with size of (2k − 2) × 1. M1 contains (k − 1) ones and (k − 1) zeros. For example, M1 = [1 1 1 0 0 0]T for k = 4. We obtain all possible permutations of M1, denoting Mi , i = 2, . . . ,N, where N = (2k−2)! (k−1)!(k−1)!

Best Answer

k = 4 ;
N = 2*k-2 ;
O = ones(k-1,1) ;
Z = zeros(k-1,1) ;
% 0's and 1's in order
iwant = [O ; Z]
% 0's and 1's in random
iwant = randsample([O ; Z],N)