I forgot to add the Mu function
function f = Mu(t,y,ti,tf,n)
m1 = 55;
m2 = 400;
m3 = 100;
k1 = 230000;
k2 = 30000;
k3 = 50000;
k4 = 3000;
n2 = 1500;
n3 = 4000;
n4 = 700;
tm = (ti+tf)/2;
t1 = tf/4;
L0 = 5;
v = 15;
A = 0.03;
M =[0 1 0 0 0 0;
-(k1+k2)/m1 -(n2+n4)/m1 k2/m1 n4/m1 0 n4/m1;
0 0 0 1 0 0;
k2/m2 n2/m2 -(k3+k2)/m2 -(n3+n2)/m2 k3/m2 n3/m2;
0 0 0 0 0 1;
k4/m3 n4/m3 k3/m3 n3/m3 -(k3+k4)/m3 -(n3+n4)/m3];
switch n
case 1
u = (A/2)*(1-cos(2*pi*v*t/L0));
case 2
u = 1*(t<tm)+(-1)*(t>=tm);
case 3
u = 0*(t<tm)+1*(t>=tm);
case 4
u = 1*(t<tm)+0*(t>=tm);
case 5
u = (A*t)*(t<=tm)+0*(t>tm);
case 6
u1 = A*t;
u2 = A*(t-2*tm);
u = u1.*(t<=tm)+u2.*(t>tm);
case 7
u1 = A*t;
u2 = A*(-t+4*t1);
u3 = A*(-t+3*t1);
u = u1.*(t<=t1)+u2.*((t>=t1)&(t<=2*t1)) +u3.*(t>=2*t1);
case 8
u = A.*((t>=t1)&(t<=2*t1));
end
vect=[0;-k1*u/m1;0;0;0;0];
f = M*y+vect;
end