• Remix
  • Share
  • New Entry

on 6 Nov 2023
  • 8
  • 36
  • 0
  • 1
  • 245
This entry contains code from the blog post "Contest Animations with INTERP1" (https://blogs.mathworks.com/community/2023/11/06/contest-animations-with-interp1/).
drawframe(1);
z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... - 1/3*exp(-(x+1).^2 - y.^2)
function drawframe(f)
% Map f onto theta
theta = interp1([0 48],[0 2*pi],f);
% Set up a landscape
peaks
shading flat
material dull
axis vis3d off
% Set up the light
ht = 4*sin(theta) + 4;
pos = [2*cos(theta) 2*sin(theta) ht];
light(Position=pos)
% The actual light is invisible, so we'll mark its position with a yellow dot
line(pos(1),pos(2),pos(3), ...
Marker=".",MarkerSize=24,Color="y")
set(gcf,Color=0.8*[1 1 1])
end
Animation
Remix Tree