function [ndisp,nload,dispval,dispfix,forcval,forcfix] = dispvalues(nnm,nem,con,h,L,xg,q);

%% Write here your boundary conditions

ndisp = 0;
nload = 0;

for i=1:nnm
    
    if (abs(xg(i,2)) < 1e-6 && abs(xg(i,1)) < 1e-6)
        ndisp = ndisp + 1;
        dispfix(ndisp,1) = 2*i-1;
        dispval(ndisp,1) = 0;
        ndisp = ndisp + 1;
        dispfix(ndisp,1) = 2*i;
        dispval(ndisp,1) = 0;
    end

    if (abs(xg(i,2)) < 1e-6 && abs(xg(i,1) - L) < 1e-6)
        ndisp = ndisp + 1;
        dispfix(ndisp,1) = 2*i;
        dispval(ndisp,1) = 0;
    end

end

help = zeros(nnm,1);
for i=1:nem
    
    inode1 = 0;
    inode2 = 0;
    inode3 = 0;
    
    if (abs(xg(con(i,1),2)-h) < 1e-6)
        inode1 = 1;
    end
    if (abs(xg(con(i,2),2)-h) < 1e-6)
        inode2 = 1;
    end
    if (abs(xg(con(i,3),2)-h) < 1e-6)
        inode3 = 1;
    end
        
    if (inode1 == 1 && inode2 == 1)
        dl = abs(xg(con(i,1),1) - xg(con(i,2),1));
        help(con(i,1),1) = help(con(i,1),1) + 0.5*q*dl;
        help(con(i,2),1) = help(con(i,2),1) + 0.5*q*dl;
    end

    if (inode1 == 1 && inode3 == 1)
        dl = abs(xg(con(i,1),1) - xg(con(i,3),1));
        help(con(i,1),1) = help(con(i,1),1) + 0.5*q*dl;
        help(con(i,3),1) = help(con(i,3),1) + 0.5*q*dl;
    end

    
    if (inode3 == 1 && inode2 == 1)
        dl = abs(xg(con(i,3),1) - xg(con(i,2),1));
        help(con(i,3),1) = help(con(i,3),1) + 0.5*q*dl;
        help(con(i,2),1) = help(con(i,2),1) + 0.5*q*dl;
    end
    
end

for i=1:nnm
    
    if (help(i,1) == 0)
        
    else
        nload = nload + 1;
        forcfix(nload,1) = 2*i;
        forcval(nload,1) = -help(i,1);
        
    end
    
end

    
    
