randomwalk
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
Cita come
Jos (10584) (2024). randomwalk (https://www.mathworks.com/matlabcentral/fileexchange/67160-randomwalk), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
Tag
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
Versione | Pubblicato | Note della release | |
---|---|---|---|
1.0.0.0 |