Finding Exact Intersection Points
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ayushi Tiwari
il 5 Apr 2021
Risposto: Star Strider
il 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)

0 Commenti
Risposta accettata
Star Strider
il 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.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!