how to run an index loop while using find function

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 件のコメント

Star Strider
Star Strider 2019 年 11 月 10 日
Use the findpeaks (or islocalmax) function to get the peaks and locations of each vector separately (EKG & PPG). Then you can get the relevant time differences from those results.
This would be much easier with your data (individual time vectors and corresponding EKG and PPG values).
Tipnirin Vajanarat
Tipnirin Vajanarat 2019 年 11 月 10 日
編集済み: Tipnirin Vajanarat 2019 年 11 月 10 日
Thank you for suggestion. But the problem is I've done using findpeak in earlier code(+filter repeating sample out and etc). in the picture is very ideal case but normally baseline shift a lot pluse there are noise and only findpeak wont do the job so I have to do other procedures in order to get each peak correctly. as you can see in the picture, 12,13 and 15 is true peak, but 14 is not.
ex1.png
In conclusion, my data at this stage will be only coordianate of marks.
Is there any function to find next data within range, return back row/colums and can work with index loop ?
Star Strider
Star Strider 2019 年 11 月 10 日
My pleasure.
There are several ways to correct a wandering baseline (the easiest in my opinion is to use a highpass filter, or bandpass filter to also remove high-frequency noise).
I cannot help you unless I have a representative sample of your data.
Tipnirin Vajanarat
Tipnirin Vajanarat 2019 年 11 月 10 日
Thank you. I've finished the filtering and marking desired peak.
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.
Can find function work with index loop?
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 日

0 投票

‘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 件)

製品

リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by