MATLAB: How to extract random data from a matrix random sample Hi everyone. I have a M rows by N columns matrix and I need to extract X random samples of it of the same size. I suposse is a simple task but I'm new at Matlab. Thanks a lot. Best Answer A=rand(10,5) %your matrix arayB=A(:)X=20; %number of random sample[v,idx]=sort(rand(1,numel(A)));Samples=B(idx(1:X)) Related SolutionsMATLAB: How to select random rows from a matrix and delete it from the original matrix for another random selection. A=rand(100); % a random matrixn=10;. idx=randsample(1:size(A,1),n) ;B = A(idx,:) ; % pick rows randomly A(idx,:)=[]; % remove those rowsidx = randsample(1:size(A,1),n) ;C= A(idx,:); MATLAB: How to generate multiple random samples of size 200 rnv=randn(200,1000); % generate 1000 column samples of 200Refer to the subsample sets as rnv(:,idx) where idx is the desired sample number. Don't even think of trying to build named variables for this. Related QuestionHow to sample a random value from a matrixHow to randomizes the order of the rows of a matrixHow to randomly and uniquely select 2000 samples from an array with 1×460800.
Best Answer