Info
この質問は閉じられています。 編集または回答するには再度開いてください。
For loop and indexing help
1 回表示 (過去 30 日間)
古いコメントを表示
I am generating a uniform random number using X=rand; I have a vector of values, say Z=[.1 .2 .3 .4 .5]. I have another vector,Y, of equal length to Z that is initiated with 0 values. Using a for loop, how can I compare the random number X to the values in Z to determine which values it falls between? For example, if X=.25, it would fall between .2 and .3. Then, Y(the index of the number that is closest to the random number), would be incremented by 1.
2 件のコメント
James Tursa
2020 年 2 月 5 日
What have you done so far? What specific problems are you having with your code?
回答 (1 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!