function [T,S,D,pH,O2,F,OBS,time,depth,epochsec,Pitch,Roll,Yaw] = avgCTD(t,s,dens,ph,o2,f,obs,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));
 D(N,1)=mean(dens(idx));
 pH(N,1)=mean(ph(idx));
 O2(N,1)=mean(o2(idx));
 F(N,1)=mean(f(idx));
 OBS(N,1)=mean(obs(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
 
