Finding Exact Intersection Points

12 ビュー (過去 30 日間)
Ayushi Tiwari
Ayushi Tiwari 2021 年 4 月 5 日
回答済み: Star Strider 2021 年 4 月 5 日
Hello,
I am currently using R2016 Version of MATLAB. I was wondering if anybody would help me with following-
(i) Getting exact intersection points of a horizontal line drawn on a curve with the main curve
(ii) Manually drawing straight lines on Matlab figures [Ellipses shown on below figure] (like if we hold shift on Microsoft office, it lets you draw a straight line)

採用された回答

Star Strider
Star Strider 2021 年 4 月 5 日
See Plot a point of intersection between 2 lines or curves for a typical approach to this problem. This will find all the intersections, however you will need to choose which ones.
The general approach would be (using created data):
x = 1:0.5:25;
y = (sin(5*pi*x/max(x))+randn(size(x))/10+1)*1E+10;
bluline = 1.49E+10;
zci = find(diff(sign(y - bluline)));
for k = 1:numel(zci)
idxrng = max(1,zci(k)-1) : min(numel(x),zci(k)+1);
x_int(k) = interp1(y(idxrng),x(idxrng),bluline);
y_int(k) = interp1(x(idxrng),y(idxrng),x_int(k));
end
figure
plot(x, y, '-k', [min(x) max(x)],[1 1]*bluline,'-b')
hold on
plot(x_int, y_int, 'sr')
hold off
grid
Then choose the intersections you want to keep.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by