I have a 1 by 124 matrix and I want to choose 'n' where n can be 1, 2or 3 from every 4 elements randomly.
This is my code but currently it selects 1 every 4. How can I make it generic, that is it selects 2 or 3 out of 4.
m = length(elements); nof4 = m/4; randSelect = randi([1 4],1,nof4); inds = randSelect+(0:nof4-1)*4; output= elements(inds);
Thanks
Best Answer