- /
-
Diffusion/Reaction
on 1 Dec 2023
- 10
- 144
- 3
- 2
- 808
function drawframe(nn)
function img = makeCircle(img, center, radius, value)
[x, y] = meshgrid(1:size(img,1), 1:size(img,2));
img((x - center(1)).^2 + (y - center(2)).^2 <= radius.^2) = value;
end
function lap = lapl(x,dist)
lap = (circshift(x,1,1)+circshift(x,-1,1)+circshift(x,1,2)+circshift(x,-1,2)-4*x)/dist^2;
end
range = [1:24 24:-1:1];
persistent caps;
if(nn==1)
caps = {};
imgsz=256;
singleCircleImage = zeros(imgsz);
singleCircleImage = makeCircle(singleCircleImage, [imgsz/2 imgsz/2], 30, 1);
u = 1-singleCircleImage;
v = singleCircleImage;
ru = 0.2;
rv = 0.1;
f = 0.0820;
k = 0.06;
Ts = 1;
steps = 160000;
capsstep = floor(steps/24);
for i=1:steps
if(mod(i-1,capsstep)==0)
caps{end+1} = 1-u;
end
nu = ru*lapl(u,1)-u.*(v.^2)+f*(1-u);
nv = rv*lapl(v,1)+u.*(v.^2)-v*(f+k);
u = u+Ts*nu;
v = v+Ts*nv;
end
end
im = caps{range(nn)};
im = imbinarize(im,0.5);
imshow(im, [])
colormap parula
end