      function   w= loading(x,rL,node,nL)
%------------------------------------------------------------
%////////////////////////////////////////////////////////////
%------------------------------------------------------------
%     LOADING FUNCTION ON BEAM
%     
%     This m-file is to accompany the MATLAP script file
%     winkler.m for the solution of beams on elastic 
%     foundations.  Three cases are provided as examples.
%     The user may keep these and simply add to them.
%
%------------------------------------------------------------
%     w is positive if acting down (negative y-direction)
%     x    = distance from left hand end of beam
%     rL   = total length of beam
%     node = node number being considered
%     nL   = number of load points
%
%------------------------------------------------------------
%     CE 560 Advanced Mechanics of Materials 
%     Department of Civil Engineering
%     Colorado State University
%     Erik Thompson
%     November 16, 1999
%------------------------------------------------------------
      
      icase = 2 ;
    
      if icase == 1 ;
%        -------------------
%        Sine loading
%        -------------------
	 c = 8.0*atan(1.0)/rL ;
	 w = sin(c*x) ;

      elseif icase == 2 ;
%        --------------------------------
%        uniform load between x=a and x=b
%        --------------------------------
         a = -1;   
         b = rL +1;
	 %          The above assures loading
	 %          over entire length of beam

	 w = 0.0;
	 if x >= a;
	    if x <= b;
	       w =  1;
	    end
         end ;

      elseif icase == 3 ;
%        ----------------------------------------
%        Concentrated load, P,  at (or near) x=pt.
%        ----------------------------------------
         P  = -1.0;
         pt = rL/2 ;   % load is in center of beam

	 dx = rL/(nL-1) ;
	 w  = 0 ;
	 if pt > (x - dx*0.5) ;
	    if pt < (x + dx*0.5)  ;
	       w = P/dx ;
	    end 
	 end 

      else ;
%        -------------------
%        Loading undefined
%        -------------------
         msg = ['=========================================================='
	        ' Something is wrong here, you have not specified a loading'
	        ' Check the <icase> designation in your loading.m file     '
                '==========================================================']
         error( '---' )
      end ;

