File Exchange

image thumbnail

2D random walk confined in a circular domain with reflective boundaries

version 1.0.0.0 (2.12 KB) by Sanaz Sadegh
2D random walk confined in a circular domain with reflective boundaries

7 Downloads

Updated 11 Dec 2016

View License

Generates a random walk (RW) with m steps. The x and y components of each step are drawn from a normal distribution with standard deviation sigma. The RW is confined to a circle of diameter d with reflecting boundary conditions. X0 and Y0 are the initial coordinates of the random walk inside the circle. Output is a vector of positions of the particle.

Cite As

Sanaz Sadegh (2020). 2D random walk confined in a circular domain with reflective boundaries (https://www.mathworks.com/matlabcentral/fileexchange/60673-2d-random-walk-confined-in-a-circular-domain-with-reflective-boundaries), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Sanaz Sadegh

Citation:

Sadegh, S., 2017. Single Molecule Fluorescence Measurements of Complex Systems (Doctoral dissertation, Colorado State University).

Sanaz Sadegh

Citation:
function H=circle(center,radius,NOP,style)
%---------------------------------------------------------------------------------------------
% H=CIRCLE(CENTER,RADIUS,NOP,STYLE)
% This routine draws a circle with center defined as
% a vector CENTER, radius as a scaler RADIS. NOP is
% the number of points on the circle. As to STYLE,
% use it the same way as you use the rountine PLOT.
% Since the handle of the object is returned, you
% use routine SET to get the best result.
%
% Usage Examples,
%
% circle([1,3],3,1000,':');
% circle([2,4],2,1000,'--');
%
% Zhenhai Wang <zhenhai@ieee.org>
% Version 1.00
% December, 2002
%---------------------------------------------------------------------------------------------

if (nargin <3),
error('Please see help for INPUT DATA.');
elseif (nargin==3)
style='b-';
end;
THETA=linspace(0,2*pi,NOP);
RHO=ones(1,NOP)*radius;
[X,Y] = pol2cart(THETA,RHO);
X=X+center(1);
Y=Y+center(2);
H=plot(X,Y,style);
axis square;

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Acknowledgements

Inspired by: Draw a circle.