필터 지우기
필터 지우기

Averaging Intervals on a Graph

조회 수: 2 (최근 30일)
Rachel Hillner
Rachel Hillner 2020년 11월 29일
답변: Rohit Pappu 2020년 12월 30일
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

답변 (1개)

Rohit Pappu
Rohit Pappu 2020년 12월 30일
If only the starting and ending time stamp need to be selected, the following syntax needs to be used
meanTriggBR = zeros(17, 1);
meanTriggGSR = zeros(17, 1);
meanHR = zeros(17, 1);
for i = 1:length(TriggStartTime)-1
%% Select elements in vector , corresponding to TriggStartTime(i) and TriggEndTime(i) position
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

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by