function beta = barBeta(Etot,Efrac,Etotd,Efracd,mode_anal)
%
%  Name:  barBeta.m
%
%  Usage:  beta = barBeta(Etot,Efrac,Etotd,Efracd,mode_anal)
%
%  Calculates the raw damage index for each subdivision of 1 bar element
%       over all the modes
%
%  Follows the formulation presented in "Damage Detection Algorithms Applied
%   to Experimental and Numerical Modal Data from the I-40 Bridge," LA-13074-MS,
%   by Farrar and Jauregui
%
%  Input:
%	Etot(i)=int(0,L,Phipp^2)=total strain energy of the element for the undamaged ith mode 
%	Efrac(i,j)=energy of the jth subdivision for the undamaged ith mode
%	Etotd(i)=int(0,L,Phipp^2)=total strain energy of the element for the damaged ith mode 
%	Efracd(i,j)=energy of the jth subdivision for the damaged ith mode
%
%  Output:
%	betanum=((Efracd(1,:)/Etotd(1)+1)+(Efracd(2,:)/Etotd+1) +...)
%	betaden=((Efrac(1,:)/Etot(1)+1)+(Efrac(2,:)/Etot+1) +...)
%  beta = betanum ./ betaden
%

%  Notes:
%  Work needs to be done on the best way to combine multiple modes
%	and whether or not to include the +1
%
%  Version SWD970403
%
%  Author(s): Scott W. Doebling, doebling@lanl.gov
%     (based on 'findBeta' by Phillip J. Cornwell, cornwell@lanl.gov)
%
%  Institution: Los Alamos National Laboratory,
%               ESA-EA
%
%  Copyright (c) 1997, The Regents of the University
%       of California. (See top level of code for
%       full copyright statement.)
%

%  Initialize components of beta

betanum=zeros(1,size(Efrac,2));
betaden=zeros(size(betanum));

for i=mode_anal
   
   betanum = betanum + (Efracd(i,:)+Etotd(i))/Etotd(i);
   betaden = betaden + (Efrac(i,:)+Etot(i))/Etot(i);
   
end

beta = betanum ./ betaden;

return
