How to find intersection of data sets

12 ビュー (過去 30 日間)
Andrew
Andrew 2014 年 1 月 10 日
コメント済み: Image Analyst 2014 年 1 月 13 日
Hi I'm very new to Matlab and programming in general. I have two curves each represented by data sets of x,y coordinates. I want to find the point at which the two lines intersect. Obviously I could plot both sets and then find the intersection just by sight, but I want to do it mathematically.
The curves need to be evaluated by spline to be a piecewise polynomial, but after that I don't know how to solve them to find the intersection.

回答 (2 件)

Image Analyst
Image Analyst 2014 年 1 月 10 日
Do you want to find the index where they are closest? What is no index matches and the crossing point is in between indexes? Do you want to find out where the cross in between indexes? So you'd have to set one cubic equal to the other in between the two indexes where it crosses.
  3 件のコメント
Andrew
Andrew 2014 年 1 月 13 日
I used a combination of your suggestion of equating the cubic functions at the relevant indices and Azzi's method to find the relevant indices. It was much easier once I figured out how to dig into the spline structure. Thanks very much!
Image Analyst
Image Analyst 2014 年 1 月 13 日
Glad you got it working.

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


Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 10 日
Look at this example
x=0:0.01:10;
y1=sin(x);
y2=cos(x);
plot(x,y1,x,y2)
idx=sign(y2-y1)
i1=strfind(idx,[1 -1]);
i2=strfind(idx,[-1 1]);
i3=find(idx==0);
idx=unique([i1 i2 i3])
  1 件のコメント
Andrew
Andrew 2014 年 1 月 13 日
Thanks very much! I used a combination of your method to find the relevant indices and Image Analyst's suggestion of equation the cubic functions at those indices.

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

カテゴリ

Help Center および File ExchangeSplines についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by