MATLAB: Generating a random binary matrix binarymatrixrandomly Hello, I want to generate randomly a (nxm) matrix of binary variables (0 and 1) in matlab. Is there someone who has a suggestion? Thanks. Best Answer A = randi([0 1], n,m) Related SolutionsMATLAB: Select randomly “N” rows of a matrix try:N=2; % no. of rows neededM=rand(5) % generate a 5x5 matrix randomc=randperm(length(M),N) B=M(c,:) % output matrix MATLAB: How to replace elements in top third, middle third, and bottom third of matix Your row indexing is wrong.The first n rows are 1:n which you have correct.The second n rows indexing is n more that the first set, so simply add n: n + (1:n)The third n rows indexing is n more than the second set, which I will let you figure out (it's pretty simple) Related QuestionRandom fun.How to generate 500 random matrices by loopFunction that combines sub matrices into one matrixGenerate Random Sample between [0,1)How to make a matrix elements randomly distributedRandom Generation of Binary Orthogonal Matrix of Size n * n with MatlabHow to generate random integer between two no (say 12 and 35) without repeat? randperm(n) give only 1 to n, but I need m to n.
Best Answer