i have a problem with my plot, i am not getting any values and the system gives me an empty plot.

조회 수: 1(최근 30일)
Ammar Anayi
Ammar Anayi 2021년 10월 10일
편집: VBBV 2021년 10월 10일
a = 0;5;
i0H2 = 10^(-7);
i0Zn = 10^(-5);
C = 7;
R = 8;314;
T = 298;15;
F = 96485;
E0H2 = -0;83;
E0Zn = -1;27;
n = [-1,1];
EH2 = n + E0H2;
EZn = n + E0Zn;
iH2 = @(n)(i0H2 *( exp((a*F*n)/(R*T)) - exp((-a*F*n)/(R*T)))) ;
iZn = @(n) (i0Zn * (exp((a*F*n)/(R*T)) - exp((-a*F*n)/(R*T))));
Log_iH2 = log10(iH2(n));
Log_iZn = log10(iZn(n));
plot(Log_iH2, EH2)
hold on
plot(Log_iZn, EZn)
hold on
  댓글 수: 3
Matt J
Matt J 2021년 10월 10일
Matlab is calculating what you asked it to. We cannot know what you really intended to calculate.

댓글을 달려면 로그인하십시오.

채택된 답변

John D'Errico
John D'Errico 2021년 10월 10일
Look at what you did.
a = 0;5;
First, maybe you think this creates a vector in a? Instead, it just sets a to 0. Then it dumps 5 into the bit bucket.
i0H2 = 10^(-7);
i0Zn = 10^(-5);
C = 7;
R = 8;314;
T = 298;15;
F = 96485;
E0H2 = -0;83;
E0Zn = -1;27;
Again, I wonder if you understand that just dumps the second number after the semi-colon into the bit bucket?
n = [-1,1];
EH2 = n + E0H2;
EZn = n + E0Zn;
iH2 = @(n)(i0H2 *( exp((a*F*n)/(R*T)) - exp((-a*F*n)/(R*T)))) ;
iZn = @(n) (i0Zn * (exp((a*F*n)/(R*T)) - exp((-a*F*n)/(R*T))));
Log_iH2 = log10(iH2(n))
Log_iH2 = 1×2
-Inf -Inf
Log_iZn = log10(iZn(n))
Log_iZn = 1×2
-Inf -Inf
Finally, you try to plot those numbers. Since they are infinities, what do you expect to be plotted?
What you really wanted to do here is a complete guess. I won't even try to make one.

추가 답변(1개)

VBBV
VBBV 2021년 10월 10일
편집: VBBV 2021년 10월 10일
a = 0.5; % perhaps this
i0H2 = 10^(-7);
i0Zn = 10^(-5);
C = 7;
R = 8.314; % here ... assume some gas constant
T = 298.15; % here as well
F = 96485;
E0H2 = -0.83; % also here
E0Zn = -1.27;
n = [-1 1]; % experiment with this also
EH2 = n + E0H2;
EZn = n + E0Zn;
iH2 = @(n) (i0H2 *( exp((a*F*n)/(R*T)) - exp((-a*F*n)/(R*T)))) ;
iZn = @(n) (i0Zn * (exp((a*F*n)/(R*T)) - exp((-a*F*n)/(R*T))));
Log_iH2 = log10(iH2(n));
Log_iZn = log10(iZn(n));
plot(real(Log_iH2), EH2, real(Log_iZn), EZn,'linewidth',2);grid
May be you have some constants defined incorrectly in your code,

Community Treasure Hunt

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

Start Hunting!

Translated by