I have an array that is 512 rows by 256 columns (i.e Nrows=512, Ncols=256) and I want the 2-d coordinates of a random sample of size 10000 without replacement from this array. I managed to do this with the code below but is seems rather clunky. Seems like there is a cleaner way to do this. Any help appreciated.
Nrows=512; Ncols=256;row_mat = zeros(Nrows,Ncols);col_mat = zeros(Nrows,Ncols);for i=1:Nrows row_mat(i,:) = i; endfor i=1:Ncols col_mat(:,i) = i; endind = [row_mat(:) col_mat(:)];[temp,idx] = datasample(ind(:,1),10000,'Replace',false);I = [ind(idx,1) ind(idx,2)]; % This is my list of 10000 unique random coordinates
Best Answer