How do I figure out the (x, y) values of where two lines intersect on a graph?

7 次查看(过去 30 天)
Below I have code that plots two equations and I am trying to figure out how to find the (x,y) values of where the two equations intersect on this graph.
code
x = 0:.1:9;
q=1.6022e-19
C=28.73
T=273+C
k=1.3806e-23
Is=1.0e-12
V= 0:0.01:9
n=1
Vt=(k*T)/q
Id=Is*((exp(V/(n*Vt)))-1)
plot(V,Id)
axis([-1,0.6,-0.1,2])
grid on
title('V-T Characteristics of Diode')
xlabel(' Voltage ')
ylabel(' Current ')
hold on
I = (-1/5000)*x + .0018;
plot(x,I)

回答(1 个)

Star Strider
Star Strider 2019-10-31
First, ‘x’ and ‘V’ have to have the same numbers of elements (unless you’re defining them as functions, in which case you can use fzero or fsolve to determine the intersection).
With that constraint, this works:
x = linspace(0, 9);
q=1.6022e-19;
C=28.73;
T=273+C
k=1.3806e-23;
Is=1.0e-12;
V= x;
n=1;
Vt=(k*T)/q;
Id=Is*((exp(V/(n*Vt)))-1);
loglog(V,Id)
axis([-1,0.6,-0.1,2])
grid on
title('V-T Characteristics of Diode')
xlabel(' Voltage ')
ylabel(' Current ')
hold on
I = (-1/5000)*x + .0018;
plot(x,I)
xint = interp1(Id-I, x, 0);
yint = (-1/5000)*xint + .0018;
plot(xint, yint, 'pg')
producing:
xint =
0.546332230872042
yint =
0.001690733553826

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by