How do I figure out the (x, y) values of where two lines intersect on a graph?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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)
0 comentarios
Respuestas (1)
Star Strider
el 31 de Oct. de 2019
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
2 comentarios
Star Strider
el 31 de Oct. de 2019
My pleasure!
If my Answer helped you solve your problem, please Accept it!
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!