Using the findpeaks function with threshold

31 次查看(过去 30 天)
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

回答(1 个)

Devineni Aslesha
Devineni Aslesha 2020-1-14
编辑:Devineni Aslesha 2020-1-14
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!

Translated by