How can I solve findpeaks() error?

12 visualizzazioni (ultimi 30 giorni)
Ezz El-din Abdullah
Ezz El-din Abdullah il 27 Ago 2017
Commentato: Ganavi Mg il 7 Feb 2018
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 Commento
Ganavi Mg
Ganavi Mg il 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));

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 27 Ago 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 Commenti
Ezz El-din Abdullah
Ezz El-din Abdullah il 27 Ago 2017
The data is attached.
I used the command:
[locs,pks]=findpeaks(y,x)
Walter Roberson
Walter Roberson il 28 Ago 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)

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by