Finding Distance Between Points and a Curve

Hi All,
I have attached two plots I would like to analyze. In both of these plots, I would like to find the vertical distance between most of the points (excluding the points that are left of the curves) and the curve. As in, for each point, I would like to imagine a vertical line extending from the point to the curve, and then find the length of this line. Ultimately, I would like to have produced two column vectors, a and b, for each of the two plots, and then create one final column vector, a^2+b^2.
Does anybody have any insight as to how to do this?
Please let me know if I could provide more helpful information as well.
Thanks

4 件のコメント

David Hill
David Hill 2020 年 2 月 24 日
Do you have the equation of the curves? If you do, it would be easy.
Adam Danz
Adam Danz 2020 年 2 月 24 日
One approach would be
  1. use min(redline), max(redline) to get the lower and upper bounds of the x values for the red line.
  2. determine which scatter points are within those bounds and store their x-values and store them in a vector as xq.
  3. use vq = interp1(x,v,xq) to interpolate the redline (x,y) coordinates at the new xq values to get the corresponding vq values.
  4. Then subtract vq from the y values of the scatter points to get the vertical distance.
Jonathan Pinko
Jonathan Pinko 2020 年 2 月 25 日
Adam Danz's approach worked perfectly.
Thank you.
Adam Danz
Adam Danz 2020 年 2 月 26 日
Thanks for the feedback! Sounds like you implemented it without any problems.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeVector Fields についてさらに検索

製品

リリース

R2019b

タグ

質問済み:

2020 年 2 月 24 日

コメント済み:

2020 年 2 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by