Finding Exact Intersection Points

8 Ansichten (letzte 30 Tage)
Ayushi Tiwari
Ayushi Tiwari am 5 Apr. 2021
Beantwortet: Star Strider am 5 Apr. 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)

Akzeptierte Antwort

Star Strider
Star Strider am 5 Apr. 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.

Weitere Antworten (0)

Produkte


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by