# Thread: Matlab diffusion limited aggregation

1. ## Matlab diffusion limited aggregation

1. The problem statement, all variables and given/known data

Hello, I have this project due for next Friday. I need help. Its on diffusion limited aggregation. A topic which is unfamiliar to me. I know exactly how to do the problem, but I don't know how to code it correctly. Basically I allow a seed particle to be in a location in a 9 x 9 matrix. Another particle is put into this matrix with a random location. basically just have to show that my code gives an image like the usual fractal images.

2. Relevant equations

None.

3. The attempt at a solution

Here's my code for the random walk;

Code:
]
% Daniel Lordan_108576939_ComputationalProject_MinimumGoal
clear all % clears all variables

xD = 0; % Holds vector of the previous values x has taken
yD = 0; % Holds vector of the previous values y has taken
rD = 0; % Used when calculating the  distance form origin
x_position = 0; % Start position at origin
y_position = 0; % Start position at origin

num_steps = 2000;
n = 9;
% Sets n equal to nine

xx = round(rand(n));
% creates a 9 x 9 array of zeros or ones ie creates an array of random
% numbers between 0 and 1

% this is just to generate some data for a 2-D "top-view" plot,

colormap([0 0 0;1 1 1])
% creates a colormap of black and white

imagesc(xx)
% plots the matrix xx as an image

axis square
% makes the plot square, as opposed to the usual rectangle

save(['E:\Matlab Project\matrix_xx.txt'], 'xx', '-ASCII','-TABS')
% save the content of xx into a txt file

perm_col = randperm(4);
% this generates a column vector containing a random permutation of the
% integers from 1 to 4

dir_mov = perm_col(1);
% the first element of perm_col will be a random number between 1 and 4
% and could be used to determine the direction of the next random walk step

for ctr = 1:(num_steps-1)
direction = randperm(4); % Direction is chossen randomly from numers 1, 2, 3, 4
if direction(1) == 1
x_position = x_position + 1; % Go East
elseif direction(1) == 2
x_position = x_position -1; % Go West
elseif direction(1) == 3
y_position = y_position + 1; % Go North
elseif direction(1) == 4
y_position = y_position -1; % Go South
end

end

plot(xD, yD)
hold on
Is that the correct coding for a random walk and how would I bring the actual dla into this problem. Thanks for anyone's help. It will be greatly appreciated as i'm freaking out and I know that I won't be able to do this.