how to run an index loop while using find function

조회 수: 3 (최근 30일)
Tipnirin Vajanarat
Tipnirin Vajanarat 2019년 11월 10일
편집: Tipnirin Vajanarat 2019년 11월 11일
I have two sets of (time) array. By using the time of red mark(ECG) as indicated in the picture. I'm trying to sweep to the right by fixed range (peakgap) to find the blue mark by using find function with condition RpeakTime<PPG1peakTime<PPG1peakTime+peakgap.
I'm trying to figure it out to use find function with index loop. How can I get the answer data of every red plot in array using for loop.
this is my code but I know it does not work
PPG1Psize = numel(PPG1peakTime);
peakgap = ((PPG1Psize)/(3*tend)); %estimate delay time between each ECG peak
for j=1:numECG
[rows,columns] = find(PPG1peakTime>RpeakTime(i) & PPG1peakTime<(RpeakTime(i)+peakgap));
end
  댓글 수: 6
Image Analyst
Image Analyst 2019년 11월 10일
Did you see the last sentence of Star's comment?
Tipnirin Vajanarat
Tipnirin Vajanarat 2019년 11월 11일
편집: Tipnirin Vajanarat 2019년 11월 11일
However I figure it out. but thank you for all the suggestions! really appreciate it
This is my code
k=1;
for i = 1:(numel(RpeakTime)-1) %% in case that last plot of ECG does not have following PPG
while PPG1peakTime(k) <= RpeakTime(i)
k=k+1;
if PPG1peakTime(k) > RpeakTime(i)
PAT(i) = PPG1peakTime(k) - RpeakTime(i);
end
end
end
PAT = PAT.';

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2019년 11월 10일
‘But I'm stuck at finding a proper function to find A single PPG coordinate near ECG in fixed range and make it work with index loop. it sounds simple but I can not find a proper one.
You may not need to use a loop, or find.
Try this:
EKGlocs = 1:20:250; % Create EKG R-Wave Locations
PPGlocs = 5+cumsum(randi([15 25], 1, 13)); % Create PPG Peak Locations
PPGdiff = bsxfun(@minus, PPGlocs, EKGlocs); % Differences Between Argument Vectors
PPGabs = EKGlocs + PPGdiff; % Absolute Values Of PPG Peak Indices
This would be easier with your data.
  댓글 수: 2
Tipnirin Vajanarat
Tipnirin Vajanarat 2019년 11월 11일
Thank you. This also works
Star Strider
Star Strider 2019년 11월 11일
As always, my pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by