How to use find here?
Afficher commentaires plus anciens
Hi, I have the points of a curve. After I plot it, I want to find the points that the curve is on zero. I tried this code:
on1 = find(d_gsr == 0)
but matlab gave me this answer:
on1 =
Empty matrix: 1-by-0
Would anyone help me to do this?
Réponse acceptée
Plus de réponses (2)
KSSV
le 9 Juil 2017
You define a small value and find the abs values less then or equal to this value. This is the approach to seek the values from flottants.
theps=0.0001 ;
on1 = find(abs(d_gsr) <= theeps);
1 commentaire
Ghazal Hnr
le 9 Juil 2017
Modifié(e) : Ghazal Hnr
le 9 Juil 2017
Image Analyst
le 9 Juil 2017
0 votes
Attach your data. Chances are there are no elements that have a pure zero as a value. I'm guessing that what you want is where your data points cross the y axis but there are actually no elements at that x location. For example if you have (x,y) = (4, 10), and the next element at (5, -3), a line connecting them will cross the y=0 line at some x value. And I'm guessing that you want the x value. But there is no element of your x array that has that value. So you'll need to find it using functions like fzero(), roots(), etc.
4 commentaires
Ghazal Hnr
le 9 Juil 2017
Modifié(e) : Ghazal Hnr
le 9 Juil 2017
Ghazal Hnr
le 9 Juil 2017
Modifié(e) : Ghazal Hnr
le 9 Juil 2017
Image Analyst
le 9 Juil 2017
Yes, that's one way. Or use interp1 on both x and y to get a bunch of points in between and then use the method KSSV showed you. This is a discrete approximation, which may well be close enough, rather than a theoretical/analytical answer like fzero() fill give, but for that you need to assume some model, like the "line" between points is a straight line or cubic spline, etc.
I didn't even go to the website because if you can't open the website and get the data from it, then I probably won't be able to either.
Ghazal Hnr
le 9 Juil 2017
Modifié(e) : Ghazal Hnr
le 9 Juil 2017
Catégories
En savoir plus sur Exploration and Visualization 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!