MATLAB: Random selection randomrow I have a matrix size of 96×249.How can i select 48 rows randomly and store it into a new matrix of 48×249.I have values in matrix as decimal numbers. Best Answer T = randperm(96);NewMatrix = OldMatrix(T(1:48),:); Related SolutionsMATLAB: How to indexing directly multiple row use linear indices,read this: https://www.mathworks.com/help/matlab/ref/sub2ind.htmlWith your example,colInd = repmat(1:size(randm_no,2),2,1);linind = sub2ind(size(randm_no),randm_row_NUm(:),colInd(:));vvvv_simple = randm_no(linind);you can reshape it if you want, vvvv_simple = reshape(vvvv_simple,size(vvvv))the result is the same for both methods,>> vvvvvvvv = 48 48 33 38 3 8 22 43 33 5>> vvvv_simplevvvv_simple = 48 48 33 38 3 8 22 43 33 5 MATLAB: Zero fill You can try something like this:oldMatrix = ones(42,52); % The original matrixnewMatrix = zeros(42,60); % The new matrix (with zeros)newMatrix(1:42, 1:52) = oldMatrix; % Overlap the original matrix in the new matrixHope it helps ;-) ! Related QuestionHow to randomly generate an alphabet within a given rangeHow to generate random matrix from another oneRandom fun.How to extract part of matrix on given dimension while this dimension is a variableConverting hh:mm:ss into secondsRearrange the dimension of lat and lon in matrix
Best Answer