Random walk or stepping
古いコメントを表示
hello, i have a 5x5 matrix and i am standing at 2,2 location, now from here i have to take one step and jump to new value. i can take jump in all 4 directions i,e i-1,i+1,j-1,j+1 with equal probability of 0.25, and also i have to update my location for making a counter loop for continous movement inside matrix.how can i code it using randperm ? or any other command available ?
5 件のコメント
Walter Roberson
2018 年 11 月 25 日
What should happen if you reach an edge and randomly select to go outside?
randperm() is not going to help you with this. Consider randi()
Image Analyst
2018 年 11 月 25 日
Is this homework? Just compute the candidate next location. If it's outside of your boundaries, then just get another value, which will most likely be in a different direction and be inside the box.
Muzaffar Habib
2018 年 11 月 26 日
Muzaffar Habib
2018 年 11 月 26 日
Walter Roberson
2018 年 11 月 26 日
To "bounce back to the same location" you can use techniques such as
new_x_position = max( min(new_x_position, maximum_x_position), minimum_x_position )
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!