0

I am working in a project that intended to extract ECG features. I used wavelet transform. I successfully detect all waves including R peaks. Now, I want to measure P wave duration. first, I thought to find the onset and offset of the P wave. then, I can count how many samples in duration. My question is when I used the following code it returns empty matrix !!!!!.( I tried to find the P wave onset from the point that is crossing the zero value with reference to P peaks(P peaks location. That is, I created a window of 201 samples in which I am looking for the nearest sample that it's value close to zero in this window). Can any one help please. (Matlab code)

% P duration
pdon = [];
% y is my filtered signal
for i = 1:1:length(Ploc);
pon = Ploc(i)-200:Ploc(i);
if (y(pon)<=0 & y(pon+1)>0) 
found = (pon);
pdon = [pdon found];
pdon_amp = y(pdon);
end
end
figure(111)
plot(y)
hold on
stem(pdon,pdon_amp,'r*')
hold off
Saleh
  • 284
  • 1
  • 3
  • 15
  • Your problem is in the `if`, `pon` is a vector of size 200, which makes `(y(pon)<=0 & y(pon+1)>0)` a boolean vector of size 200, and the only way it would pass as an `if` condition is if all values are `true`, which I think is impossible in your case. – Noel Segura Meraz Jul 01 '16 at 08:46
  • Thank you for your help. can you help me please with a working code. – Saleh Jul 02 '16 at 17:15
  • Sorry, but I haven't worked with ecg and don't fully understand what are you doing or trying to achieve, I was just pointing out a logic error. Maybe if you add a small sample of your data, and the output you expect we might be able to help you better – Noel Segura Meraz Jul 02 '16 at 17:37

0 Answers0