Finding Exact Intersection Points

8 visualizaciones (últimos 30 días)
Ayushi Tiwari
Ayushi Tiwari el 5 de Abr. de 2021
Respondida: Star Strider el 5 de Abr. de 2021
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)

Respuesta aceptada

Star Strider
Star Strider el 5 de Abr. de 2021
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.

Más respuestas (0)

Categorías

Más información sobre Annotations en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by