Clear Filters
Clear Filters

for finding peak. i tried findpeaks(). but its not working

6 views (last 30 days)
for the given
waveform
  2 Comments
Adam
Adam on 6 Aug 2014
You need to give more information really. In what way does it not work? Assuming the waveform you show there is in discrete form in an array I would think findpeaks should work ok.
I sometimes find myself wanting to write my own peak-finding algorithm after trying findpeaks, but that usually comes from me identifying something specific about its output that I don't like and can't seem to paramaterise well enough to give what I want. For a general case it should be fine though.
Image Analyst
Image Analyst on 6 Aug 2014
So now you have two threads on the same question. Why did you want that? What was wrong with your original discussion you had started in http://www.mathworks.com/matlabcentral/answers/146486-hi-i-have-a-signal-i-want-to-calculate-peak-and-area-of-the-signal

Sign in to comment.

Answers (2)

Nir Rattner
Nir Rattner on 6 Aug 2014
Edited: Nir Rattner on 6 Aug 2014
Assuming that the image provided is the input format for the signal, you can use the “find” function with a threshold to get all of the black pixels which represent the signal. You may need to use the “smooth” function to get remove some of the unwanted blurriness and noise from the signal. At that point you can simply use the “findpeaks” function with the “y” data:
I = imread('PPG.jpg');
% Threshold to pull signal pixels
[y, x] = find(I(:, :, 1) < 150);
% Smooth to remove image artifacts
ySmooth = size(I, 1) - smooth(x, y, 0.02);
plot(x, ySmooth, 'r');
hold on;
axis equal;
% Find peaks of Y Data
[peaks, locations] = findpeaks(ySmooth);
plot(x(locations), ySmooth(locations), 'o');

Chad Greene
Chad Greene on 6 Aug 2014

Community Treasure Hunt

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

Start Hunting!