I think I might first ask, "do I need to write new code to do this?" Both particle and particle-in-cell simulation codes for diffusion, DLA, plasma physics, Boltzmann-type equations, Smolchuski-type equations, Navier-Stokes and many more have been written, debugged, tested, optimized, parallelized and made available...
If the answer is still yes, first consider how you'd rewrite this in vector notation:
for p=1:P;
for i = 1:length(t)-1
x(i+1,p) = x(i,p)+sig*sqrt(dt)*randn;
end
end
Or you'll likely find the execution time grinding to a halt pretty quickly (profile on/profile off/profview are friends). As to the particular question you're asking: "Looking at the first cell, how would I go about calculating the mean (sum column / #columns), of the first cell."... is there a reason
mean(theCellArray{n})
wouldn't work? You might also consider extending the array into the 3rd dimension rather than using cells, if equal numbers of particles of each species is acceptable. Most functions which don't explicitly depend on specific array shapes (i.e. other than linear algebra itself) will extend intuitively with 3- or higher-dimensional arrays. Consider also if it's necessary to store the -entire- time history of the entire simulation, since that has a way of eating up memory, or if a finite amount of total history can be stored and much smaller running outputs computed based on that.