function OTS=OneThirdSimp(t,y)

% t is a row vector of domain values and y a vector of dependent values
% t and y must have the same length

if length(t)~=length(y)
disp('the two data vectors must have equal length') 

elseif ceil(length(t)/2)-length(t)/2 == 0
disp('there must be an even number of data intervals (so an odd number of data points)') 

elseif diff(t)-t(2)+t(1)~=zeros(1,length(t)-1)
disp('data vectors must be rows and each data interval must be the same length') 

else
h=t(2)-t(1);
L=2:(length(t)-1);
M=mod(L,2)==0;
M=[ 0 M 0];
K=mod(L,2)~=0;
K=[ 0 K 0];
E=M.*y;
O=K.*y;

OTS=h/3*(y(1)+y(length(y))+4*sum(E)+2*sum(O));






end


