How do I get values out of a scatter plot that are in between the data points

10 次查看(过去 30 天)
Ok, so I have a dataset with a column of x values and a column of y values. I have plotted them as a scatter plot here.
What I want to do is extract x values for a given y value. E.g. what are the x values when y = 17? As you can see, a given y value might not actually have a "plotted" x value.

采纳的回答

Image Analyst
Image Analyst 2020-2-15
编辑:Image Analyst 2020-2-15
You could try spline() or interp1(). See attached demo.
Red points are the original "knots" and the blue points are the interpolated points.
You can maybe reverse the x and y and plug the y into spline to get the x.
Or else make a few million interpolated points and use ismembertol(), though there may be a more direct and accurate way such as finding the two points on either side of hte y value and using bilinear interpolation.
  3 个评论
Image Analyst
Image Analyst 2020-2-15
Please remember to attach your data. Make it easy for people to help you, not hard. I'll check back later today.
Usama Ahmed
Usama Ahmed 2020-2-15
I've attached the data I'm using as well as the code. DataAnalyis1 contains the code. DataVariables contains the data I'm using.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spline Postprocessing 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by