%%%%%%%%%%%%%%%%  beam.m  %%%%%%%%%%%%%%%%%%%%
global node elem idofgivendof
% Read in nodal and element connectivity data from
% files: nodes.dat and elements.dat
load nodes.dat
load elements.dat

% Read in displacement boundary condition data from the file dispbc.dat
load dispbc.dat
ne=length(elements(:,1));
for i=1:ne
    elem(i).end1=elements(i,2);
    elem(i).end2=elements(i,3);
    elem(i).E=elements(i,4);
    elem(i).A=elements(i,5);
    elem(i).I=elements(i,6);   
end
clear elements;
n=length(nodes(:,2));
for i=1:n
    node(i).x=nodes(i,2);
    node(i).y=nodes(i,3);
end
clear nodes;

idofgivendof=((dispbc(:,2)-1)*3+dispbc(:,3))';
n=length(idofgivendof);
for i=1:n
    dispval=dispbc(i,4);
    nodno=dispbc(i,2);
    switch dispbc(i,3)
        case 1
            node(nodno).u=dispval;
        case 2
            node(nodno).v=dispval;
        case 3
            node(nodno).th=dispval;
        otherwise
            h= errordlg('Maximum dof is 3. Some entries in the boundary',...
                ' conditions are wrong','Incorrect dof specification in dispbc.dat');
    end
end