function output=integrate2(x,y)
% Output type: VECTOR.
%currently: uses CUMTRAPZ. 
%output = cumtrapz(x,y); 

% Computes the integral of y with respect to x (by simple summation) and 
% outputs the resulting vector. Integral is taken to start from zero, although
% the first element is not zero (elements represent the outside sum).
% See "Integral" for just the net sum (definite integral). 

s = size(x); 

  if s(2)>s(1), 
    xx = [0 x]; 
    yy = [0 y]; 
  else, 
    xx = [0; x]; 
    yy = [0; y]; 
  end; 

output2 = cumtrapz(xx,yy); 
output = output2(2:length(output2)); 

% this produces weird negative values so alter to fix that ... 
output = output-output(1) + y(1)*(x(2)-x(1)); 




