%---------------------
% PROGRAM wire.m
%---------------------

  clear
% ---------------------
% INPUT DATA
% ---------------------
  load MSHDAT   -ASCII
  load NODES    -ASCII

  TENS  = MSHDAT(1);
  NUMEL = MSHDAT(2);

  NUMNP=NUMEL+1;

  for  I=1:NUMNP
     XORD(I)=NODES(I,1);
     NPBC(I)=NODES(I,2);
     U(I)   =NODES(I,3);
     F(I)   =NODES(I,4);
  end

% --------------
% INITIALIZATION
% --------------
  IB=2;
  for I=1:NUMNP;
     for  J=1:IB; 
        SK(I,J)=0.0;
     end;
  end;

% ----------------------------- 
% FORMATION OF STIFFNESS MATRIX
% ----------------------------- 
  for I=1:NUMEL;
     RL=XORD(I+1)-XORD(I);
     RK=TENS/RL;
     SK(I,1)=SK(I,1)+RK;
     SK(I,2)=SK(I,2)-RK;
     IP1=I+1; 
     SK(IP1,1)=SK(IP1,1)+RK;
  end;

% -------------------- 
% BOUNDARY CONDITIONS
% -------------------- 
  for I=1:NUMNP;
     if NPBC(I) == 1;
        SK(I,1)=SK(I,1)*1.0E+06; 
        F(I)=U(I)*SK(I,1); 
     end;
  end;

% ------------------------------ 
% CALL EQUATION SOLVER
% ------------------------------ 
  U =  sGAUSS(SK,F,NUMNP,IB);

% -----------
% OUTPUT DATA
% -----------
  save XORD XORD -ASCII
  save U U -ASCII

  plot(XORD,U)
  grid
  xlabel('Distance along wire')
  ylabel('Deflection of wire')
  title(['Deflection of a tightly'...
         ' stretched wire'])
