• Remix
  • Share
  • New Entry

on 10 Nov 2023
  • 6
  • 48
  • 0
  • 0
  • 353
drawframe(1);
Write your drawframe function below
function drawframe(f)
% https://blogs.mathworks.com/cleve/2018/07/09/the-oeis-and-the-recaman-sequence/
% https://oeis.org/ A005132
m = floor(63/24*f);
a = 0;
R = a;
pm = -1;
shg
plot(0,0,'k.')
s = 114;
axis([0 2*s -s s])
axis([0 2*s -s s])
axis equal
set(gca,'xtick',[],'ytick',[])
for n = 1:m-1
if a > n && all(a - n ~= R)
a = a - n;
else
a = a + n;
end
R(n+1) = a;
t = (0:1/32:1)*pi;
c = (R(n+1)+R(n))/2;
r = n/2;
x = r*cos(t)+c;
y = pm*r*sin(t);
line(x,y)
line(a,0,'marker','.')
drawnow
pm = -pm;
end
line(a,0,'marker','.')
end
Animation
Remix Tree