How can I solve findpeaks() error?

조회 수: 10 (최근 30일)
Ezz El-din Abdullah
Ezz El-din Abdullah 2017년 8월 27일
댓글: Ganavi Mg 2018년 2월 7일
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
Ezz El-din Abdullah 2017년 8월 27일
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)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by