I found a solution using a different approach:
nt = ncread('pressure.nc', 'datetime');
Times = datetime(nt, 'convertFrom', 'posixtime', 'Format', 'yyyy-MM-dd HH:mm:ss');
pressure = ncread('pressure.nc', 'pressure');
T = timetable(Times, pressure);
dt = 1 %timestep (1 second)
meth = 1
interval = 1200;
timespan = length(T.pressure)-interval;
for jj = 1:interval:timespan
d = T.pressure(jj+(0:interval-1));
s = T.Times(jj);
[X] = myfunction(d, dt, meth)
XT = [XT; X]
Time = [Time; s]
end
TT = timetable(Time, XT);