How do I figure out the (x, y) values of where two lines intersect on a graph?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Star Strider
am 31 Okt. 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 Kommentare
Star Strider
am 31 Okt. 2019
My pleasure!
If my Answer helped you solve your problem, please Accept it!
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!