How can I solve findpeaks() error?

10 次查看(过去 30 天)
I'd like to fix this error that appears when I use findpeaks:
Error using findpeaks
Expected X to be finite.
Error in findpeaks>parse_inputs (line 215)
validateattributes(Xin,{'double'},{'real','finite','vector','increasing'},'findpeaks','X');
Error in findpeaks (line 134)
= parse_inputs(Yin,varargin{:});
Thank you.
Edit:
I have attached the data which I would like to find the peaks on.
  1 个评论
Ganavi Mg
Ganavi Mg 2018-2-7
Hi Even I am getting same error. Please give some suggestions.My code is clc; clear all; load('DATA_01_TYPE01.mat'); [n, p] = size(sig); t=1:n; plot((1:1000),sig(2,1:1000)); xlabel('samples') ylabel('sample amplitude') title('User1') figure; n=1000; ts =0.0001; ws = 2*pi/ts; f = fft(sig(2,1:1000)); w = ws*(-n/2:(n/2)-1)/n; plot(w,abs(f)) xlabel('frequency'); ylabel('amplitude'); title('fast fourier transform of PPG DATA'); data = size(sig(2,1:1000)); pks= findpeaks(data,sig(1:1000));

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2017-8-27
findpeaks() does not work on data that includes +/- inf or nan. You will need to remove that data before running findpeaks()
xfin = min(realmax, max(-realmax, x));
if any(isnan(xfin(:)))
error('Sorry, cannot compensate for nan data');
end
findpeaks(xfin, ...)
  5 个评论
Ezz El-din Abdullah
The data is attached.
I used the command:
[locs,pks]=findpeaks(y,x)
Walter Roberson
Walter Roberson 2017-8-28
The data does not appear to have been attached yet.
yfin = min(realmax, max(-realmax, y));
if any(isnan(yfin(:)))
error('Sorry, cannot compensate for nan data');
end
findpeaks(yfin, x)

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by