MATLAB: How to generate three random matrices from 20 percent of the rows of a 2000 by 80 matrix, using for loop for loopindexingmatricespercentrandom Let's X=[2000 by 80]. Now I want to get X1, X2 and X3 randomly from X. Each matrix is 20 percent of the X. Please help me out. Thank you Best Answer I don't see why a loop is necessary. Is it?A = rand(2000,80); % test arrays = size(A,1);nrows = round(s*0.2);X1 = A(randperm(s,nrows),:);X2 = A(randperm(s,nrows),:);X3 = A(randperm(s,nrows),:); Related SolutionsMATLAB: How to select a random number from set 5:20:2000 idx=5:20:2000;rand_num=idx(randi(length(idx))); MATLAB: Matrix’s and percents x = rand(10);x1 = zeros(10);x1(x<0.2) = 1;x1(0.2<=x&x<0.6) = 2;x1(x>=0.6) = 3;or if you want precise 20%, 40% and 40%, you can dox = zeros(10);k = randperm(100);x(k(1:20)) = 1;x(k(21:60)) = 2;x(k(61:100)) = 3; Related QuestionPercent ErrorPercent residualSelecting values randomly from datasetHow to find the 80 and 20 percent positions on a gaussian profile – Penumbral widthPlace array in a matrix
Best Answer