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
% i=1;
% npoints=length(t); 
% iae=zeros(1,size(y,2));
% 
% % 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
% 
% iae=iae';
% 

t_diff = t(2:end)-t(1:end-1);
y=abs(y);
y_sum = y(1:end-1,:)+y(2:end,:);
iae = .5*t_diff'*y_sum;
iae=iae';



