How do you graph two equations on the same graph?

3 views (last 30 days)
Here is the code that I am using for my two equations I am able to graph them separately but when I graph them together my graph is not correct. I am trying to figure out where the two equations intersect.
plot 1
x = 0:.1:10;
I = (-1/5000)*x+(.0018);
plot(x,I)
plot 2
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)

Answers (2)

Star Strider
Star Strider on 31 Oct 2019
Considering your present code, use the hold function.
Using your code:
x = 0:.1:10;
I = (-1/5000)*x+(.0018);
plot(x,I)
hold on % hold on
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)
hold off % hold off
Experiment to get the result you want.

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 31 Oct 2019
Hi,
x = 0:.1:10;
I = (-1/5000)*x+(.0018);
plot(x,I), hold on
%plot 2
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), legend('x vs. I', 'V vs. Id')
% as two subplots
figure
subplot(211)
plot(x, I)
subplot(212)
plot(V, Id)
Check the values of coefficients/parameters. They seem to be incorrectly typed in.

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!