function iae=iae(t,y)
% This is the function iae.m
% Simple integration routine made for computing IAE of time signal usubg trapez integration
%
%    y - time signal vector
%    t - time signal vector



% Initialize
iae=0;
i=1;
npoints=length(t); 

% Integrate
while i  < npoints,

  yavg = (y(i) + y(i+1))/2;
  dt = t(i+1) - t(i);
  int = abs(yavg)*dt;
  iae = iae + int;
    i=i+1;
  
end

