PHYC452Biophysics:Assignments/HW3 4

MATLAB code
%452: Biophysics, HW#3 % (4) Numerical warmup: Compute numerically a 30 second trajectory of a % membrane protein diffusing with D=0.05 micron^2/s. Use 1000 time steps to % generate the trajectory. Use the computer program of your choice % (but MATLAB is recommended). Give the code, and the trajectory with % properly labeled axes. dt=30/1000; %time interval between each point D=0.05; %units are micron^2/s x=zeros(1000,1); y=zeros(1000,1); t=(0:999)*dt;

%=4*D*dt so then r=sqrt(4*D*dt);

for ii=2:1000 %chose a random direction: phi=rand*2*pi; x(ii)=x(ii-1)+r*cos(phi); y(ii)=y(ii-1)+r*sin(phi); end figure plot(x,y) xlabel(' X Position (microns)') ylabel(' Y Position (microns)') title('A 30 second trajectory of a particle diffusing in 2D with D=0.05 micron^2/s') axis equal