clear ;clc;n=300;t=100;x = zeros(n,t);y = zeros(n,t);xtrack = zeros(n,t);ytrack = zeros(n,t); for i= 2:t for j=1:n dx = rand(n,t); dy = rand(n,t); x= x + dx; y= y + dy; end x =[dx;x]; xtrack; y =[dy;y]; ytrack; scatter(x,y) axis({ x x y y}) pause (0.01)end
Could anyone help push me in the right direction , i have been trying to compute amodel that mimics the random steps of molecules undergoing Brownian motion. this has to track 300 molecules in an array and repeat this for 100 time steps
I have attempted different ways but I keep getting an error messaged that disagrees with my code , i have tripled checked the vector lengths and they do agree unless i am missing something. Thanks a lot for reading
this is the message i keep getting regardless what i alter –> Error using scatter (line 61) X and Y must be vectors of the same length. Error in (line 20) scatter(x,y)
please see below my code
Best Answer