how to get in the function values above zero only and the plot stop at zero and above

13 views (last 30 days)
I want only to get Ucell0, Ucell1, Ucell2 the value above zero , and i dont want to show in the plot values below zero
------------------------------------------------------------------------------------
global A
R=8.314;
F=96485;
Alfa=0.1668;
n=2;
c1=174512;
c2=5485;
T=343;
T1=353;
T2=363;
k=123;
b=-c2/T;
jL=2000
g=-237.15*10^3
j0=exp(b)*c1;
j=0:1:2000;
c3=R*T;
c4=Alfa*n*F;
c5=log((jL)./(jL-j));
Uact=(c3/c4)*log(j/j0);
Ucon=(c3/c4)*c5
Uohm=j*(0.01/k);
E=(-1*(g)/(n*F))
Ucell0=(E-Uact-Ucon-Uohm);
P0=abs(Ucell0).*(j)
eff=Ucell0./E;
.............................................................%
b1=-c2/T1;
j01=exp(b1)*c1;
c13=R*T1;
c4=Alfa*n*F;
c5=log((jL)./(jL-j));
Uact1=(c13/c4)*log(j/j01);
Ucon1=(c13/c4)*c5
Uohm1=j*(0.01/k);
E1=(-1*(g)/(n*F))
Ucell1=(E-Uact-Ucon-Uohm);
P1=abs(Ucell1).*(j)
eff1=Ucell1./E1
...............................................................%
b2=-c2/T2;
j02=exp(b2)*c1;
c23=R*T2;
c4=Alfa*n*F;
c5=log((jL)./(jL-j));
Uact2=(c23/c4)*log(j/j02);
Ucon2=(c23/c4)*c5;
Uohm2=j.*(0.01/k);
E2=(-1*(g)/(n*F))
Ucell2=(E2-Uact2-Ucon2-Uohm2);
P2=abs(Ucell2).*abs(j);
eff2=Ucell2./E2;
xlabel("j (A/m^2)")
ylabel ("U(V)")
plot(j,Ucell0,j,Ucell1,j,Ucell2)

Accepted Answer

Star Strider
Star Strider on 10 Nov 2022
Use a logical index mask —
global A
R=8.314;
F=96485;
Alfa=0.1668;
n=2;
c1=174512;
c2=5485;
T=343;
T1=353;
T2=363;
k=123;
b=-c2/T;
jL=2000
jL = 2000
g=-237.15*10^3
g = -237150
j0=exp(b)*c1;
j=0:1:2000;
c3=R*T;
c4=Alfa*n*F;
c5=log((jL)./(jL-j));
Uact=(c3/c4)*log(j/j0);
Ucon=(c3/c4)*c5
Ucon = 1×2001
0 0.0000 0.0001 0.0001 0.0002 0.0002 0.0003 0.0003 0.0004 0.0004 0.0004 0.0005 0.0005 0.0006 0.0006 0.0007 0.0007 0.0008 0.0008 0.0008 0.0009 0.0009 0.0010 0.0010 0.0011 0.0011 0.0012 0.0012 0.0012 0.0013
Uohm=j*(0.01/k);
E=(-1*(g)/(n*F))
E = 1.2289
Ucell0=(E-Uact-Ucon-Uohm);
P0=abs(Ucell0).*(j)
P0 = 1×2001
NaN 0.8814 1.6397 2.3514 3.0328 3.6915 4.3321 4.9576 5.5702 6.1714 6.7626 7.3445 7.9182 8.4842 9.0432 9.5955 10.1418 10.6822 11.2171 11.7469 12.2717 12.7919 13.3076 13.8190 14.3263 14.8296 15.3292 15.8251 16.3175 16.8064
eff=Ucell0./E;
.............................................................%
b1=-c2/T1;
j01=exp(b1)*c1;
c13=R*T1;
c4=Alfa*n*F;
c5=log((jL)./(jL-j));
Uact1=(c13/c4)*log(j/j01);
Ucon1=(c13/c4)*c5
Ucon1 = 1×2001
0 0.0000 0.0001 0.0001 0.0002 0.0002 0.0003 0.0003 0.0004 0.0004 0.0005 0.0005 0.0005 0.0006 0.0006 0.0007 0.0007 0.0008 0.0008 0.0009 0.0009 0.0010 0.0010 0.0011 0.0011 0.0011 0.0012 0.0012 0.0013 0.0013
Uohm1=j*(0.01/k);
E1=(-1*(g)/(n*F))
E1 = 1.2289
Ucell1=(E-Uact-Ucon-Uohm);
P1=abs(Ucell1).*(j)
P1 = 1×2001
NaN 0.8814 1.6397 2.3514 3.0328 3.6915 4.3321 4.9576 5.5702 6.1714 6.7626 7.3445 7.9182 8.4842 9.0432 9.5955 10.1418 10.6822 11.2171 11.7469 12.2717 12.7919 13.3076 13.8190 14.3263 14.8296 15.3292 15.8251 16.3175 16.8064
eff1=Ucell1./E1
eff1 = 1×2001
Inf 0.7172 0.6671 0.6378 0.6169 0.6008 0.5875 0.5763 0.5666 0.5580 0.5503 0.5433 0.5369 0.5311 0.5256 0.5205 0.5158 0.5113 0.5071 0.5031 0.4993 0.4957 0.4922 0.4889 0.4857 0.4827 0.4797 0.4769 0.4742 0.4716
...............................................................%
b2=-c2/T2;
j02=exp(b2)*c1;
c23=R*T2;
c4=Alfa*n*F;
c5=log((jL)./(jL-j));
Uact2=(c23/c4)*log(j/j02);
Ucon2=(c23/c4)*c5;
Uohm2=j.*(0.01/k);
E2=(-1*(g)/(n*F))
E2 = 1.2289
Ucell2=(E2-Uact2-Ucon2-Uohm2);
P2=abs(Ucell2).*abs(j);
eff2=Ucell2./E2;
xlabel("j (A/m^2)")
ylabel ("U(V)")
m1 = Ucell0 > 0;
m2 = Ucell1 > 0;
m3 = Ucell2 > 0;
plot(j(m1),Ucell0(m1), j(m2),Ucell1(m2), j(m3),Ucell2(m3))
.
  5 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Signal Generation and Preprocessing 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!