MATLAB: Randomly select elements of an array matrix Hi How i can select randomly elements from a matrix o array I have the matrix and i want to select "x" numbers of elements thanks Best Answer msize = numel(YourMatrix);idx = randperm(msize);YourMatrix(idx(1:x))If you have a fairly new version of MATLAB, you can instead usemsize = numel(YourMatrix);YourMatrix(randperm(msize, x)) Related SolutionsMATLAB: Newbie needing to create matrix elements dependent on other elements A = your Nx6 matrixA(:,7) = sqrt(sum(A(:,1:3).*A(:,1:3),2)); % The RSS of the 1st 3 columns by row MATLAB: 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 Related QuestionDear all:I have a 6* 3 matrix. I wanna choose 4rows randomly. how can I selecete all array in a rows randomly without replacementHow to select a random element in a row of matrixSelecting random number from martrixHow to randomly pick a row (A) from a matrix give the same value from array (B)Array slicing scattered rows
Best Answer