Controlled Random Generator based off of two columns
古いコメントを表示
I have two columns in Table A, the first column is randomly generats values between 10 and 3600 but the second column needs to be randomly generated based on the first columns values. The second column needs to be a value equal to or less than column 1's equivalent row and if the random value is lower and not equal to it, it must be divisible by traffic.R_P.
I tried the below for loop but of course it is generating random numbers not divisible by traffic.R_P. Not sure how to create a controlled random generator with values divisible by another column.
example is
traffic.R_P = [2500 1200 200 400]
traffic.XX = [2500 60 0 10] %CORRECT and Want
traffic.XX = [2400 60 1100 300] %Incorrect and what I am getting from below code
traffic.R_P = randi([1,36],TDT_Total_ID,1)*100; %is working fine and correctly populating
for T_row = 1 : TDT_Total_ID
traffic.XX(R_dith_row,1) = randi([1,(traffic.R_D(T_row,1)/10)],T_row,1)*10;
end
3 件のコメント
dpb
2019 年 8 月 24 日
" first column is randomly generat[e]s values between 10 and 3600"
randi([1,36],TDT_Total_ID,1)*100;
will not generate values between 10 and 3600, but between 100 and 3600 and will only be in increments of 100.
"two columns in Table A, ..."
but there's not a variable A in sight so it's not at all clear how all the above relates?
What's the actual population of possible values this first column consists of? The second then has to be a selection from that population's factors to be evenly divisible.
Tessa Aus
2019 年 8 月 24 日
dpb
2019 年 8 月 25 日
"t traffic.XX can be any values from 10 to 3600"
But in example
traffic.XX = [2500 60 0 10] %CORRECT and Want
you have a 0 element which the comment says is "%CORRECT and Want"???
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!