Find indexes in time-series signal

조회 수: 3 (최근 30일)
JCanal
JCanal 2018년 11월 12일
댓글: KSSV 2018년 11월 13일
Hi,
Im searching for x indexes of a given y value in a time-series signal.
What function should I use since the exact y value Im looking for sometimes do not exist?

답변 (1개)

KSSV
KSSV 2018년 11월 13일
편집: KSSV 2018년 11월 13일
YOu may have a look on this example code:
% signal
x = linspace(0,2*pi)' ;
y = sin(x) ;
% Get the x index for yi
yi = randsample(y,1) ;
% Do interpolation
xi = interp1(y,x,yi) ;
% GEt the index
idx = knnsearch([x y],[xi yi]) ;
value = [xi yi]
iwant = [x(idx) y(idx)]
  댓글 수: 1
KSSV
KSSV 2018년 11월 13일
YOu may also use this approach:
% signal
x = linspace(0,2*pi)' ;
y = sin(x) ;
% Get the x index for yi
yi = randsample(y,1) ;
% Check for abolute zero
idx = abs(y-yi)<=10^-3 ;
yi
iwant = [x(idx) y(idx)]

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by