--- /dev/null
+function y_dot=collar_ekv(t, y, g, k, m, b)
+z = y(1);
+z_dot = y(2);
+
+y_dot = zeros(2,1);
+y_dot(1) = z_dot;
+y_dot(2) = -g - ((k/m)*z*(1-((3*b)/(2*sqrt((z.^2) + (b.^2))))));
\ No newline at end of file
--- /dev/null
+function [value,isterminal,direction] = collar_events(t, y, stopheight)
+
+value = y(1) - stopheight;
+isterminal=1;
+direction=0;
+end
\ No newline at end of file
--- /dev/null
+%BANAN
+stopheight=0;
+g = 9.82;
+k = 100;
+m = 0.5;
+b = 0.3;
+
+
+t_max = 10;
+z_0 = sqrt(3)*b;
+
+
+options = odeset("Events", @(t,y) collar_events(t, y, stopheight), ...
+ 'RelTol', 1e-3,'AbsTol', 1e-6, 'MaxStep', 0.01);
+
+[t_vek,Y]=ode45(@(t,y) collar_ekv(t,y,g,k,m,b), [0 t_max], [z_0 0], options);
+
+z = Y(:, 1);
+z_dot = Y(:,2);
+s = z_0 - z;
+
+subplot(1,3,1);
+p1 = plot(s, z_dot);
+xlabel("s");
+ylabel("zdot");
+title("Hastighet krage");
+
+zdotdot = zeros(length(t_vek), 1);
+for i=1:length(t_vek)
+ zdotdot(i) = -g - ((k/m)*z(i)*(1-((3*b)/(2*sqrt((z(i)^2) + (b.^2))))));
+end
+subplot(1,3,2)
+p2 = plot(s, zdotdot);
+xlabel("s");
+ylabel("ydotdot");
+title("Acceleration krage")
+
+step = 0.01;
+y = zeros(t_max/step, 1);
+v = zeros(t_max/step, 1);
+for i=0:length(new_t)
+
+ v(i+1) = g*step*i;
+ y(i+1) = z_0 - (v(i+1)*step*i/2);
+ if z_0 - (g*step*i*step*i/2) < 0
+ v = v(1:i, 1);
+ y = y(1:i, 1);
+ v = flip(v,1);
+
+ break
+ end
+end
+subplot(1,3,3)
+p3 = plot(y, v);
+xlabel("s");
+ylabel("v");
+
+max(v)
+z_dot(end)