N_UE=10unused_rows=1:N_UEwhile ~isempty(unused_rows)N_UE_rows=ceil(sqrt(randi(numel(unused_rows))))rows=unused_rows(randsample(length(unused_rows),N_UE_rows))[~,idx]=find(ismember(unused_rows,rows))unused_rows(idx)=[]end
If i run the code it executes My clarification is with respect to command line [~,idx]=find(ismember(unused_rows,rows)) after executing the code the result in the command window was
N_UE = 7unused_rows = 1 2 3 4 5 6 7N_UE_rows = 2rows = 6 4idx = 4 6unused_rows = 1 2 3 5 7N_UE_rows = 2rows = 1 3idx = 1 3unused_rows = 2 5 7N_UE_rows = 2rows = 5 7idx = 2 3unused_rows = 2N_UE_rows = 1rows = 2idx = 1unused_rows = Empty matrix: 1-by-0If rows= 6 4idx=4 6rows = 1 3idx=1 3but if rows= 5 7idx should be 5 7 but it showsidx = 2 3rows = 2idx=1
why it is so.Could anyone clarify my doubt
Best Answer