Finding Select Peaks in a Signal

3 views (last 30 days)
Sean
Sean on 1 Dec 2012
I am trying to better understand MATLab, as I am a new user. I've been working on a ECG waveform and I have been trying to add noise to it and repeat it over 10 sec. What I hope to do is then to filter it and try to analyze the signal to determine the heart rate. I hope to do this by locating the peak in each heartbeat, and dividing over time. The problem I have encountered is when using 'findpeaks'. Instead of finding the max peaks in each heartbeat, it is giving me many more peaks within the waveform. Does anyone know how to find only the max peaks in my waveform? The code I am using is below:
x1 = ecg(512); x = repmat(x1,1,10); x = x + 0.1.*randn(1,length(x)); frame = 15; degree = 0; x3 = sgolayfilt(x, degree, frame); n = 1:512; del = round(512*rand(1)) ECGW = x3(n+del); t = 1/512:1/512:10 plot(t,x3); axis([0 10 -1 1]); grid; xlabel('Time[sec]'); ylabel('Voltage'); title('Normal ECG Waveform Over Ten Seconds');
[pks,locs] = findpeaks(x3);
Any thoughts?

Answers (1)

Image Analyst
Image Analyst on 1 Dec 2012
You could threshold to suppress lower peaks:
signal(signal < thresholdValue) = 0;
Then it will find only peaks greater than the threshold.

Community Treasure Hunt

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

Start Hunting!