function [T,S,F,OBS,Biolum,Biotemp,Bioflow,time,depth,epochsec,Pitch,Roll,Yaw] = avgCTD(t,s,f,obs,biolum,biotemp,bioflow,mtime,mdepth,pitch,roll,yaw,avgint);

etime = mtime;
mtime = mtime-min(mtime); buf = avgint/2;

itime = [4*avgint:avgint:max(mtime)-4*avgint];
for N=1:length(itime);
 idx = find(mtime >= itime(N)-buf & mtime< itime(N)+buf);
 T(N,1)=mean(t(idx));
 S(N,1)=mean(s(idx));
 F(N,1)=mean(f(idx));
 OBS(N,1)=mean(obs(idx));
 Biolum(N,1)=mean(biolum(idx));
 Biotemp(N,1)=mean(biotemp(idx));
 Bioflow(N,1)=mean(bioflow(idx));
 time(N,1)=mean(mtime(idx));
 epochsec(N,1)=mean(etime(idx));
 depth(N,1)=mean(mdepth(idx));
 Pitch(N,1)=mean(pitch(idx));
 Roll(N,1)=mean(roll(idx));
 Yaw(N,1)=mean(yaw(idx));
end
 
