Can you assume that the data is always sampled uniformly every 2 minutes? That can simplify things, but the code below should be general.
Also, I'd recommend using a timetable for this, as it will make time subscripting easier.
% Cook up some synthetic data
HeartRate = 60+randi(20,[30*24,1]);
data = timetable(HeartRate,'TimeStep',minutes(2),'StartTime',datetime(2021,05,07));
data.Properties.DimensionNames{1} = 'Timestamp';
windowStart = data.Timestamp(1);
% Need to figure out where to stop so there's enough data for the last set
% of moving windows.
windowEnd = data.Timestamp(end)-hours(2);
numWindows = height(data(timerange(windowStart,windowEnd),:));
% Preallocate the p-value timetable. Split the confidence interval into 2
% vars. It could also be one 2-element wide var.
tp = array2timetable(nan(numWindows,4),'RowTimes',data.Timestamp(1:numWindows),'VariableNames',{'h','p','ciLow','ciHigh'});
for ii = 1:numWindows
start = data.Timestamp(ii);
A = data.HeartRate(timerange(start, start+hours(1)));
B = data.HeartRate(timerange(start+hours(1),start+hours(2)));
[h, p, ci] = ttest2(A,B);
tp.h(ii) = h;
tp.p(ii) = p;
tp{ii,["ciLow","ciHigh"]} = ci';
end