Finding Exact Intersection Points

8 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by