Using the findpeaks function with threshold
Show older comments
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 Comment
Meg Noah
on 12 Jan 2020
The very same question was recently asked:
Answers (1)
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:
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!