Filter löschen
Filter löschen

How to change the rng value

2 Ansichten (letzte 30 Tage)
Prabha Kumaresan
Prabha Kumaresan am 21 Mär. 2018
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 Kommentar
Steven Lord
Steven Lord am 1 Mai 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Mär. 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 Kommentare
Prabha Kumaresan
Prabha Kumaresan am 7 Mai 2018
yes the flow chart.
Walter Roberson
Walter Roberson am 7 Mai 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by