R=0;
m=1;
K=1;
L=1;
g=@(t)[0];

odefun=@(t,y)[y(2);
    -R/m*y(2)-K/m*(y(1)-L)+g(t)/m];
tspan=[0,100];
y0=[2,0];

H=[0.1,0.01,0.001];
for h=H
Nh=round((tspan(2)-tspan(1))/h);
[tn,un]=feuler(odefun,tspan,y0,Nh);

figure
plot(tn,un(:,1),'r',tn,un(:,2),'b')
legend('x(t)','x''(t)');
xlabel('t');
ylabel('numerical solution')
grid on
end