• Remix
  • Share
  • New Entry

on 4 Oct 2022
  • 7
  • 17
  • 0
  • 0
  • 267
%setup sand grid
B=219;
S=zeros(B);
%loading sand in the middle
S(110,110)=9e4;
while max(max(S))>1900
%identifiy sand pillars greater than 4
H=find(S>=4);
%take for sand grains from the tallest pillar
S(H)=S(H)-4;
%add sand to neighbours
S(H-1)=S(H-1)+1;
S(H+1)=S(H+1)+1;
S(H-B)=S(H-B)+1;
S(H+B)=S(H+B)+1;
end
%display the image
image(S)
colormap('prism');
axis equal
set(gca,"Position",[0 0 1 1])
set(gca,"YColor",'y')
set(gca,"XColor",'g')
set(gca,'TickDir','out')
Remix Tree