• Remix
  • Share
  • New Entry

on 8 Nov 2023
  • 10
  • 141
  • 1
  • 2
  • 713
drawframe(1);
Write your drawframe function below
function drawframe(f)
g = 9.8;
m = 1;
v0 = 50;
k = 0.9;
if f < 10
t1 = linspace(-100,0,15);
U = sin(0.3*t1);
h1 = 3;
plot3(U(f:f+h1),-U(f:f+h1),t1(f:f+h1),'w',LineWidth=0.7)
end
if f >= 10
t2 = linspace(0,5,38);
n = 20;
p = 10;
h = 10;
circle_theta = linspace(0,2*pi,p);
f = f - 9;
for j = 1:n
theta = j*2*pi*(1/n);
if f <= h
ts = t2(1:f);
elseif f >= h+1 && f <= 38-h
ts = t2(f-h:f);
elseif f >= 38-h+1 && f <= 39
ts = t2(f-h:38-h);
end
x = (m*v0/k)*(1-exp(-k*ts/m))*cos(theta);
y = (m/k)*((v0*sin(theta)+(m*g/k))*(1-exp(-k*ts/m))-g*ts);
for q = 1:p
plot3(x*cos(circle_theta(q)),x*sin(circle_theta(q)),y,'w')
hold on
plot3((1/2)*x*cos(circle_theta(q)),(1/2)*x*sin(circle_theta(q)),(1/2)*y,'m')
end
end
end
hold off
set(gcf,"Color","k")
daspect([1,1,1])
axis([-70 70 -70 70 -100 50])
axis off
end
Animation
Remix Tree