i am doing a step in my code where i am generating a 5 vector random variable using (randperm) where number are from 1 to 3. then i am organizing them using (unique) and calculating how many times each number is repeated.
After that if a number is mentioned once i update the code to generate 4 vector random number or even more depending on how many one time a number appeared till i reach zero.
My problem is: every time a 5 vector random numbers are generated ??!!
is there a way to fix this; here is a part of the code:
clc clear NT=5; while(NT~=0) for i=1:NT g=randperm(3,1); x(:,i) = g; end x m=unique(x); n=hist(x,m); f=sum(n==1); % calculate if a number mentioned once NT=NT-f fprintf('--\n') end