randomwalk

Create a random walk in any number of dimensions
507 Downloads
Aktualisiert 1. Mai 2018

Lizenz anzeigen

randomwalk - create random walk in arbitrary dimension
P = randomwalk(N, D) produces a N-by-D matrix P with the positions of a random walk of N steps in D dimensions, starting from (0,..,0). P(K,:) holds the coordinates of the position at step K. Each step from one position to the next is +1 or -1 along a random dimension.
With a third logical argument, randomwalk(N, D, true) creates a plot of the random walk in a new figure.

Examples:
P = randomwalk(2, 10) % -> for example
% P = [0 0 ; 1 0 ; 1 1 ; 2 1 ; 2 0 ; 2 -1 ; 3 -1 ; 3 -2 ; 2 -2 ; 2 -1]
randomwalk(1000,4,true) ; % create a plot

Zitieren als

Jos (10584) (2024). randomwalk (https://www.mathworks.com/matlabcentral/fileexchange/67160-randomwalk), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2017b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0