MATLAB: Reordering the data reordering i have values as D=[1 2 3 4 5 6 7 ] now i want to reorder the data D1=[3 4 7 1 2 6 5]this is for example, i want the order to be changed from D,without using randperm function,please help Best Answer What about generating two random numbers as indices and swapping the data of the indices? And then do this in a loop.clcD=[1 2 3 4 5 6 7 ]for k=1:10 x1=randi(length(D)); x2=randi(length(D)); dummy=D(x1); D(x1)=D(x2); D(x2)=dummyend Related SolutionsMATLAB: Replace vector duplicates with unique numbers One way:D = [2,4,5,4,1,2]n = numel(D)C = setxor(D,1:n)[U id] = unique(D)ix = setxor(id,1:n)D(ix) = C(randperm(numel(ix)))D = 2 4 5 4 1 2n = 6C = 3 6U = 1 2 4 5id = 5 1 2 3ix = 4 6D = 2 4 5 6 1 3 MATLAB: Random number within a rwo vector A(ceil(rand*numel(A))) Related QuestionWhich algorithm performs random shuffling of data in Matlab (randperm function)Non-repeating random integer generator with a seedLinear equation with multiple values for a constantHow to plot an equation of this formHow to reorder the data
Best Answer