function [I] = integral(y, t, UseSignificance, s, UseMean, mu);
% function [I] = integral(y, t, UseSignificance, s, UseMean, mu)
%
% calculates the integral of the first pulse in the signal. The result is in Volt-sec.
%
% is the given signal in 1D array format.
% is time axis in 1D array format.
% is a switch: 0 is for calculation significance function.
% ~~ is significance function of the signal.
% is a switch: 0 is for calculating the signal mean value.
% is the mean value of the signal.
% ~~* is the integral of the signal in Volt-sec.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Current state of the project and change history.
%
% Created by: Alexander Vostrikov
% Created on: 07/08/2011
%
% Version: 1.1
% Modified by: Alexander Vostrikov
% Edited on: 07/13/2011
% (a) Significance function and mean value of the signal can be set without
% calculation.
%
% List of Previous Versions:
%
% Version: 1.0
% Modified by: Alexander Vostrikov
% Edited on: 07/12/2011
%
% If you type 'help integral' on the Matlab command window, you will be
% able to see this help documentation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% beginning of code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if UseSignificance == 0
s = significance(y);
UseSignificance = 1;
end
if UseMean == 0
[mu, sigma] = background(y, UseSignificance, s);
end
a = SignificanceCut(s, 6.0);
b = a;
while y(a) > mu
a--;
end
while y(b) > mu
b++;
end
I = 0.0;
for i = a:b
I += (y(i) - mu) * (t(i+1) - t(i));
end
end
*