intersection of lines and curves

6 ビュー (過去 30 日間)
SHANTANU KSHIRSAGAR
SHANTANU KSHIRSAGAR 2020 年 5 月 12 日
コメント済み: Star Strider 2020 年 5 月 22 日
i have data in which line is plotted on a signal having pulses. I want to find out all points of intersections between the line and the curve. Right now i am able to get single point of intersection on only one side of pulse. I also need point of intersection on the other side.
  1 件のコメント
SHANTANU KSHIRSAGAR
SHANTANU KSHIRSAGAR 2020 年 5 月 12 日
also in some cases getting wrong intersection, in remaining getting error of not having unique points(intersect1).

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

採用された回答

Star Strider
Star Strider 2020 年 5 月 12 日
Try this:
D = load('intersect1.mat');
x_curve = D.x_curve;
y_curve = D.y_curve;
x_line = D.x_line;
y_line = D.y_line;
x_curve(x_curve == 0) = []; % Eliminate Spurious Points
y_curve(y_curve == 0) = []; % Eliminate Spurious Points
zci = @(v) find(v(:).*circshift(v(:), -1, 1) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector (>= R2016b)
icix = zci(y_curve - y_line(1:end-2));
figure
plot(x_curve, y_curve, x_line, y_line)
hold on
plot(x_curve(icix), y_curve(icix), 'dr')
hold off
grid
producing:
The x-values of the intersections are about 0.135 and 0.149. (They are: x_curve(icix).)
The points are dense enough that it is not necessary to interpolate them to get reasonably precise values for the intersections.
.
  10 件のコメント
SHANTANU KSHIRSAGAR
SHANTANU KSHIRSAGAR 2020 年 5 月 22 日
編集済み: SHANTANU KSHIRSAGAR 2020 年 5 月 22 日
Thank you star , I worked on your code for some time,made some changes, additions it is really helpful .
Star Strider
Star Strider 2020 年 5 月 22 日
As always, my pleasure!

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

その他の回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 5 月 12 日
編集済み: KALYAN ACHARJYA 2020 年 5 月 12 日
Have you tried this way?
data1
data2
diff=data1-data2;
small_value=?? % Define small value to deal with samll differenece also
% Make the lower as possible, though ensure that it donot missed the interconnection
idx=find(diff<small_value);
If the data1 and data2 are non floating numbers, you can do the following
idx=find(data1==data2)
  10 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 12 日
Do you mean that you are not permitted to use the functions there, or that you have technical problems when you try to use those functions?
If you are not permitted to use the functions there, then I would be concerned that if I were to give you code for this purpose, that you would not be permitted to use it.
SHANTANU KSHIRSAGAR
SHANTANU KSHIRSAGAR 2020 年 5 月 12 日
編集済み: SHANTANU KSHIRSAGAR 2020 年 5 月 12 日

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

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by