%rw_taylor clear clc close all %diffusion coefficient, mean velocity adn radius D=0.01; v=1; a=1; %timestep dt=0.1; N=1e4; %initial condition z=zeros(1,N); x=zeros(1,N); y=linspace(0,a,N); r=sqrt(x.^2+y.^2); Nsteps=1e4; time=[]; for jj=1:Nsteps %update particle locations via random walk vel=zeros(size(x)); %all particles outside the tube have zero velocity apple=find(ra); r(apple)=2*a-r(apple); x(apple)=1/sqrt(2)*r(apple); y(apple)=1/sqrt(2)*r(apple); r=sqrt(x.^2+y.^2); if mod(jj,100)==0 jj plot(z,r,'.') pause(0.01) end m1(jj)=1/N*sum(z); m2(jj)=1/N*sum(z.^2); time(jj)=jj*dt; end kappa=m2-m1.^2; figure(2) plot(time,kappa)