How to locate X value for a given Y value
Afficher commentaires plus anciens
I have Data which is Time along the x-axis and amplitude along the y -axis.
I want to know the exact time at a given value of amplitude. Its probably just one line of code but I can't seem to figure it out.
Any help would be appreciated.
Réponse acceptée
Plus de réponses (1)
the cyclist
le 1 Fév 2023
Modifié(e) : the cyclist
le 1 Fév 2023
It would be helpful if you uploaded the data. You can use the paper clip icon in the INSERT section of the toolbar.
It seems like you need either
% The exact value appears in the amplitude vector, and want to find what Time it occurs
Time(amplitude == value) % be careful here if you are comparing floating point values
or
% The exact value does not appear in the amplitude vector, so you want the
% first Time where you surpass that value
Time(find(amplitude>value,1)) % this assume the values of amplitude and time are sorted appropriately
You might also want to interpolate between times, but be more exact. Then you'll need the interp1 function.
2 commentaires
David Harra
le 2 Fév 2023
the cyclist
le 2 Fév 2023
You can't upload just your Time and amplitude vectors in a MAT file?
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
