xyRange=[1,5]; %// Starting xy range of particles
P=3; %// Number of particles generated each day
vx=0.6; vy=0.4; %// x and y velocity
X=[]; Y=[]; %// Vectors start out empty
for day=1:10 %// Generate 3 particles and add to end of vectors X and Y
X=[X;randi(xyRange,P,1)]; Y=[Y;randi(xyRange,P,1)]; %// Move all the particles
X=X+vx; Y=Y+vy;endplot(X,Y,'kd');grid on ;axis([1,50,1,50]); j = floor(X/5)+1;k = floor(Y/5);box = k*10+j;
MATLAB: How can i count number of particles in each grid box after running this code ?
matlab cvst
Best Answer