MATLAB: How to distribute 100 ones in 100 by 100 matrix randomly in all posibilities binaryMATLABmatrix array I want to make binary matrix, and distribute 100 ones in it, randomly in all possibilities. What command I have to use plz help. Best Answer indices = randi(1e4,100,1);x = zeros(100,100);x(indices) = 1; Related SolutionsMATLAB: Random matrix with fix summation For older versions of MATLAB without the randperm(n,k) syntax enabled, n=500^2; m=7000; idx=randperm(n); z=[ones(1,m), zeros(1,n-m)]; a=reshape(z(idx),500,500); MATLAB: How to set pixel values in 100*100 matrix Try something like thisimg = zeros(100, 'uint8');idx_all = 1:numel(img);idxs = cell(1,3);for i = 1:numel(idxs)-1 idx_temp = randperm(numel(idx_all), round(numel(img)/3)); idxs{i} = idx_all(idx_temp); idx_all(idx_temp) = [];endidxs{end} = idx_all;img(idxs{1}) = 50;img(idxs{2}) = 100;img(idxs{3}) = 200; Related QuestionUniformly distributed 10 number between [-100,100]Resizing the images to 100 x 100100% Classification accuracy
Best Answer