简体   繁体   中英

plot Line and curve intersection point?

i wrote the following matlab code :

L=100;
N=[0:L];
D=8.62;
Z=95;
Dmax=1./12;
X=@(N) N./((N.*D)+ Z);
X2=@(N) N./(D+ Z);

z1 = fzero(@(x) X(x)-Dmax, 0);

plot([0 100],[Dmax Dmax],'r')
hold all
fplot(X,[0 L 0 0.3],'g')
fplot(X2,[0 L 0 0.3])
plot(z1, 'ro')
legend('1/Dmax','N/(ND+Z)','N/(D+Z)','N*')

i want to plot the point of intersection between the green curve and the red line, the x- value of the intersection and a discontinuous lign connecting the intersection point to x-axis!

To plot it, you have to calculate the intersecting point. I suggest to use the symbolic toolbox, if not available a numerical solution is possible as well.

plot(solve(X(sym('a'))==Dmax),Dmax,'o')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM