function cviko4()

% Resime vrh svisly MKP
% m*u''(t) = -m*g
% u(0) = u(1) = 0

g = 9.81;

t = 0:0.01:1;
u = -0.5*g*(t.^2-t);
plot(t,u,'r')

for k=3:20
    n = 2^k, dt = 1/(n+1);
    D = (1/dt)*[-ones(n,1),2*ones(n,1),-ones(n,1)];
    
    A = spdiags(D,-1:1,n,n);
    b = g*dt*ones(n,1);
    u = A\b;
    
    hold on
    plot(0:dt:1,[0,u',0],'b')
    pause 
end