EA = 1

xy = [ 0 0 ; 4 0 ; 8 0 ; 2 3 ; 6 3 ] ;
elems = [ 1 2 ; 2 3 ; 4 5 ; 1 4 ; 4 2 ; 2 5 ; 5 3 ] ;

K = sparse(10,10) ;
for e=1:7
    nodes = elems(e,:)
    id = 2*nodes([1,1,2,2])-[1,0,1,0]
    dx = xy(nodes(2),1) - xy(nodes(1),1);
    dy = xy(nodes(2),2) - xy(nodes(1),2);
    L = sqrt(dx*dx+dy*dy);
    c = dx/L ; s = dy/L ;
    Ke = EA/L*[ c*c, c*s, -c*c, -c*s ;
               c*s, s*s, -c*s, -s*s ;
               -c*c, -c*s, c*c, c*s ;
               -c*s, -s*s, c*s, s*s ]
    K(id,id)=K(id,id)+Ke ;
end

K

%% Objektivni funkce
H=K;
f=sparse(10,1);
f(8,1) = 10 ;
f(10,1) = 10 ;


%% Nerovnosti
A=zeros(1,10);
A(1,4) = -1 ;
b=0.05;

%% Rovnosti
Aeq=sparse(4,10);
Aeq(1,1)=1 ;
Aeq(2,2)=1 ;
Aeq(3,5)=1 ;
Aeq(4,6)=1 ;
beq=zeros(4,1);

[x,fval,EXITFLAG,OUTPUT,LAMBDA] = quadprog(H,f,A,b,Aeq,beq)

LAMBDA.eqlin
LAMBDA.ineqlin