if truek=3; n=5;m=(2*k)-2;n1=k-1;N=(factorial(m))/(factorial(n1)*factorial(n1));o = ones(k-1,1) ;z = zeros(k-1,1) ;a1 = [o ; z];n2=1;for i=1:Na(:,n2)= randsample([o ; z],m)n2=n2+1;end end
MATLAB: In the following code I get matrix ‘a’ with repeated columns. How to generate it without repetition
sharing matrix
Related Question
- How to get the corresponding logic value based on the sum of vector elements
- 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)!
- Indexing an entire for loop
- Can any one help me in detecting an error in matlab code please
- Matrix problem for same values of column
- Vectorization with a loop and repmat
Best Answer