move data in randomly
1 view (last 30 days)
Image Analyst on 8 Sep 2021
See this well commented solution:
% Create sample data.
v = [ 1 3 2 5 4 7 6 9 8 0]
% Find out how many values we need to send to A.
numIndexes = round(0.6 * length(v))
% Get random indexes.
AIndexes = randperm(length(v), numIndexes);
% Extract those indexes from v and put them into a new vector called A
A = v(AIndexes)
% Whatever is in v that is not already in A, put those into B using setdiff()
B = setdiff(v, A)