%simple mass-spring-damper: 
global m b k  l0 f_ext;
m=2;
b=0.5;
k=50;
l0 = 1.5;

%first conditions: 
f_ext = inline('0');
x0 = [l0, 5];
tspan  = [0:0.01:10];
[t_1, x_1] = ode45('f_onespring', tspan, x0);
plot(t_1, x_1(:,1));

%second conditions: 
figure
f_ext = inline('3*t');
x0 = [l0, 0];
tspan  = [0:0.01:3];
[t_2, x_2] = ode45('f_onespring', tspan, x0);
plot(t_2, x_2(:,1));


global m b k  l0 f_ext;
m=2;
b=0.5;
k=50;
l0 = 1.5;
%simple 3-mass-spring-damper: 
%first conditions: 
figure
f_ext = inline('0');
x0 = [l0, 5, 2*l0, 0, 3*l0, 0];
tspan  = [0:0.01:10];
[t_3, x_3] = ode45('f_3springs', tspan, x0);
plot(t_3, x_3(:,1:2:5));

%second conditions: 
figure
f_ext = inline('sin(10*t)');
x0 = [l0, 0, 1.5*l0, 0, 2*l0, 0];
tspan  = [0:0.01:10];
[t_4, x_4] = ode45('f_3springs', tspan, x0);
plot(t_4, x_4(:,1:2:5));
