MATLAB: How can select elements randomly from two matrixes but the same position MATLAB ex: A= [1 2 3 4], B= [9 7 6 5] if select 2 in A must select 7 in B 0r 3 in A must 6 in B. Thanks for help Best Answer N = length(A); pos=randsample(1:N,1);select position randomly A(pos) B(pos) Related SolutionsMATLAB: Swap 3 random elements in an array Use randperm to select 3 elements (without replacement) from your vector.a = [4 2 3 1 5 7 6]ind = randperm(numel(a), 3)a(ind) = a(ind([3 1 2])) MATLAB: Insert into array with probability % Make some arbitrary a, b, and confidence matrixa = randi(10,[1 10]);b = 100*(1:numel(a));confidence = rand(size(a));% Replace the elements of b based on the probabilities in "confidence"pos = (confidence >= rand);b(pos) = a(pos) Related QuestionHow to select a random element in a row of matrixChange 1 to -1 in a matrixHow to choose a random value from an arrayHow to change or compliment a particular bit in the binary stringHOW TO SELECT ELEMENTS FROM DIFFERENT MATRIXExtracting data from from all rows aside from those that contain NaNRandomly select an element from a vector satisfying a conditionDisplay the value from a vector
Best Answer