![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/367414/image.png)
Plotting Intersection point on plot
213 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Cole Zajack
il 28 Set 2020
Commentato: Mayowa Milburn
il 27 Mar 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/367390/image.png)
Hello, I simply have a plot here, but everytime I run the code, I want my plot to include the point where the two lines intersect. Just simply show the intersection point and it's coordinates on the plot. Was hoping there was a way to do this instead of having to click on the intersection point with mouse.
0 Commenti
Risposta accettata
Star Strider
il 28 Set 2020
Try this:
Cpo = -0.75;a = 3.32;
M = 0.2:0.01:0.8;
Cp = Cpo./sqrt(1-M.^2);
Cp_cr = 2./(a*M.^2) .* ((((2+(a-1)*M.^2)/(a+1)) .^(a/(a-1)))-1);
xisx = interp1((Cp - Cp_cr), M, 0);
yisx = Cpo./sqrt(1-xisx.^2);
figure
plot(M, Cp)
hold on
plot(M, Cp_cr)
plot(xisx, yisx, 'pg', 'MarkerFaceColor','g')
hold off
set(gca, 'YDir','reverse')
legend('Cp', 'Cp\_cr', 'Intersection')
It would have been easier wit your actual code, rather than aan image of it.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/367414/image.png)
.
1 Commento
Mayowa Milburn
il 27 Mar 2021
Hi can you do that for simple cases of x=[1 2 3 4 5], y1=[2 4 6 8 10], y2=[3 6 9 12 15]
plot(x,y1)
plot(x,y2)
How do you apply that code to find and plot the intersect in this case?
Più risposte (1)
Ameer Hamza
il 28 Set 2020
You may also have look at this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections.
0 Commenti
Vedere anche
Categorie
Scopri di più su Lighting, Transparency, and Shading 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!