I am trying to find the mean HR, BR, and GSR for certian time intervals from a plot where instantaneous HR, BR, GSR are plotted against HRTime, BRTime, and GSRTime respectively.
It seems as though the code I wrote for the meanBR and meanGSR work because there are about 204,000 entries whereas the HR only has about 3,000. The problem is that the correct intervals are not being averaged. For example, interval 1 starts at time 40428 and ends at time 40498. My code seems to be averaging the field entries 40428 : 40498 instead of the field entries corresponding to those said time intervals. Thus, the averages that it is calculating is incorrect and will not work for HR given there are only 3000 entries. Is there anyway to average the intervals corresponding to the times on the x-axis instead of in relation to the field entry number?
My Code:
meanTriggBR = zeros(17, 1);
meanTriggGSR = zeros(17, 1);
meanHR = zeros(17, 1);
for i = 1:length(TriggStartTime)-1
meanTriggBR(i) = mean(BR(TriggStartTime(i):TriggEndTime(i)));
meanTriggGSR(i) = mean(GSR(TriggStartTime(i):TriggEndTime(i)));
meanHR(i) = mean(HR(TriggStartTime(i):TriggEndTime(i)));
end