Find indexes in time-series signal
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
KSSV
le 13 Nov 2018
Modifié(e) : KSSV
le 13 Nov 2018
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 commentaire
KSSV
le 13 Nov 2018
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)]
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!