Clear Filters
Clear Filters

How to change the rng value

2 views (last 30 days)
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 Comment
Steven Lord
Steven Lord on 1 May 2018
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.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 21 Mar 2018
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 Comments
Prabha Kumaresan
Prabha Kumaresan on 7 May 2018
yes the flow chart.
Walter Roberson
Walter Roberson on 7 May 2018
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

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!