How can I solve findpeaks() error?
7 views (last 30 days)
Show older comments
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 Comment
Ganavi Mg
on 7 Feb 2018
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));
Answers (1)
Walter Roberson
on 27 Aug 2017
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 Comments
Walter Roberson
on 28 Aug 2017
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)
See Also
Categories
Find more on Transforms 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!