Using the findpeaks function with threshold

82 views (last 30 days)
INDS
INDS on 12 Jan 2020
Edited: Devineni Aslesha on 14 Jan 2020
ECG=load('ECG.csv');
f_s=350;
N=length(ECG);
t=[0:N-1]/f_s;
[pks,locs] = findpeaks(ECG,'MinPeakHeight',threshold)
plot(t,ECG,t(locs),pks,'.')
I want to find the peaks of my ECG trace using findpeaks but I am unsure of how to use the function. I have tried using this code and changing threshold to a value. Is there a way of having it inputted by the user?
I would also like these peaks to be stored as a 1D vector. I was wondering if anyone could help out with the code!
Kind regards

Answers (1)

Devineni Aslesha
Devineni Aslesha on 14 Jan 2020
Edited: Devineni Aslesha on 14 Jan 2020
The threshold value can be inputted by the user as shown below.
prompt = 'What is the threshold value? ';
threshold = input(prompt);
The syntax ‘[pks,locs] = findpeaks(ECG,'MinPeakHeight',threshold)’ stores the peaks above threshold value as a 1D vector in the variable ‘pks’.
For more information, refer the following link:

Community Treasure Hunt

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

Start Hunting!