How to change the rng value

2 次查看(过去 30 天)
code:
unused_rows=1:6
while ~isempty(unused_rows)
N_UE_rows=2;
rng(3)
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
The above code works how to run the code by having different numbers of rng say for example rng(12),rng(2),rng(1).
  1 个评论
Steven Lord
Steven Lord 2018-5-1
Prabha, you've asked this same question or a slight variation several times now. It's still not clear to me exactly what you're trying to do. Please take a short break from coding and write out IN WORDS NOT CODE a description of what you're trying to do. Explain it as though you were explaining it to someone who has no idea what problem you're trying to solve. That may help us understand your ultimate goal and allow us to suggest more effective solutions to that problem.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2018-3-21
list_of_rng_seeds = [12, 2, 1];
rng_usage_idx = 0;
unused_rows = 1:6;
while ~isempty(unused_rows)
N_UE_rows = 2;
rng_usage_idx = mod(rng_usage_idx, length(list_of_rng_seeds)) + 1;
rng(rng_usage_idx);
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
  28 个评论
Walter Roberson
Walter Roberson 2018-5-7
Flow charts are usually fairly straight forward to write once you have the code. I find reference to a commercial tool http://www.aivosto.com/visustin.html which can generate flow charts from MATLAB. See also https://stackoverflow.com/questions/5518200/automatically-generating-a-diagram-of-function-calls-in-matlab

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by