get the x-value of a point on curve
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ahmed salah
el 20 de Feb. de 2020
Comentada: the cyclist
el 20 de Feb. de 2020
I draw a curve between two vector of points, not a function, how can I get the x-value of a certain y-value of the curve?
2 comentarios
Respuesta aceptada
the cyclist
el 20 de Feb. de 2020
When you say "get", do you mean from the vectors, or only from the curve?
If you mean from the data, you can do, for example
x(y==0.25)
(You might need to be careful if y is not exactly 0.25, due to floating point precision.)
2 comentarios
the cyclist
el 20 de Feb. de 2020
My solution assumes the y value you are looking for is in the original vector. Sky Sartorius's solution is preferred if the y value is not in the original vector, but you want to interpolate.
Más respuestas (1)
Sky Sartorius
el 20 de Feb. de 2020
This is a table lookup / interpolation problem. For your data, you'll first have to make sure there aren't any repeated y values.
yQuery = -2.6e8; % Example query point.
[Y,ind] = unique(y,'stable')
X = x(ind);
x = interp1(Y,X,yQuery)
2 comentarios
the cyclist
el 20 de Feb. de 2020
The best way to thank a contributor is to upvote and/or accept their answer. This rewards them with reputation points, and also directs future users to solutions.
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!