could anyone tell me how to find the values of N_rng to have all possible combinations
1 回表示 (過去 30 日間)
古いコメントを表示
code:
N_UE=[4 6];
N_rng=[1 2 3 4 5 6 7 8 9 10]
for t=1:length(N_UE)
for s=1:length(N_rng)
this_seed = N_rng(s);
fprintf('Below results are for rng = %d\n', this_seed)
rng(this_seed);
unused_rows=1:N_UE(t);
while ~isempty(unused_rows)
N_UE_rows=ceil(sqrt(randi([numel(unused_rows)])));
if (N_UE_rows+1)==numel(unused_rows)
N_UE_rows=numel(unused_rows);
end
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows));
unused_rows(idx)=[];
end
end
end
for the above code how to find the values of N_rng inorder to have all possible combinations of 4 and 6
9 件のコメント
Guillaume
2018 年 5 月 2 日
編集済み: Guillaume
2018 年 5 月 2 日
As stated in the other identical question, if you want a specific sequence then don't use a random generator.
You have yet to explained why you are using random number generators but then want to constrain that generator to generate a specific number that creates a given output.
Frankly, you're wasting everyone time because we can't see the logic behind what you're doing.
At the end of the day, if you're hell bent on finding a seed that gives you a specific sequence, feel free to try them all yourself. You don't need our help for that, you just need a lot of time. Mathworks does not document if the default random number generator is 32 or 64 bits, you only need to test 4,294,967,296 different values if 32 bits and 18,446,744,073,709,551,616 different values if 64 bits. Of course, given the weirdness of your code there is no guarantee that any of these values will generate your desired sequence.
Now maybe if instead of using flawed code and flawed algorithm you explained better what this is all about, we could help.
Dennis
2018 年 5 月 2 日
Maybe you could explain why you want to use randi.
If you are just looking for all possible combinations of numbers from 1:n i recommend you try out perms(1:n).
If you actually need seeds that generate specific results you can use Walter Robersons' code he provided you in another thread.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Waveform Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!