function [A] = initclampedmatrix(n)

% initializes the clamped-clamped A matrix for solving the Euler-Bernoulli equation
assert(n >= 4, 'Cannot initialize matrix with n<4');

A = sparse(n,n);
A(1,1) = 16;
A(1,2) = -9;
A(1,3) =  8/3;
A(1,4) = -1/4;
A(2,1) = -4;
A(2,2) =  6;
A(2,3) = -4;
A(2,4) =  1;
A(n-1,n-3) =   1;
A(n-1,n-2) =  -4;
A(n-1,n-1) =   6;
A(n-1,n)   =  -4;
A(n,n-3)   =  -1/4;
A(n,n-2)   =   8/3;
A(n,n-1)   =  -9;
A(n,n)     =  16;

for x=3:n-2
    A(x,x-2)=1;
    A(x,x-1)=-4;
    A(x,x)=6;
    A(x,x+1)=-4;
    A(x,x+2)=1;
end