% ƒr�[ƒ€‚Ì�Ã“I•ÏŒ`�i—¼’[ŒÅ’è�j

L = 10; A = 2;
n = 6; h = L/n;
E = 200;
fext = 5;

e0 = 2*ones(n+1,1);
e0(1) = 1; e0(n+1) = 1;
e1 = (-1)*ones(n+1,1);
K = (E*A/h)*spdiags([e1 e0 e1], -1:1, n+1, n+1); % ŽO�d‘ÎŠp�s—ñ
fprintf("�„�«�s—ñ K\n");
full(K)

f = zeros(n+1,1);
f(n/2+1) = fext;
fprintf("ƒxƒNƒgƒ‹ f\n");
f

A = zeros(n+1,2);
A(1,1) = 1; A(n+1,2) = 1;
fprintf("�s—ñ A\n");
A

mat = [  K,   -A; ...
        -A',  zeros(2,2) ];
vec = [ f; zeros(2,1) ];
sol = mat \ vec;
un = sol(1:n+1);
lambda = sol(n+2:n+3);

fprintf("ŒvŽZŒ‹‰Ê\n");
un
lambda

fprintf("�L‚Ñ\n");
un(2:n+1)-un(1:n)
