Info
この質問は閉じられています。 編集または回答するには再度開いてください。
I want to change a variable with every iteration either randomly, how do i do that ?
1 回表示 (過去 30 日間)
古いコメントを表示
I want to change a variable with every iteration either by +1 or -1 randomly and keep the overall variable in between +5 to -5
0 件のコメント
回答 (1 件)
Ameer Hamza
2020 年 10 月 22 日
Something like this will work
x = 0;
for i = 1:100
x = min(max(x + 2*(rand()>0.5)-1, -5), 5)
end
2 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!