how to get in the function values above zero only and the plot stop at zero and above
13 views (last 30 days)
Show older comments
Mariam Almheiri
on 10 Nov 2022
Commented: Star Strider
on 11 Nov 2022
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)
0 Comments
Accepted Answer
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
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)")
m1 = Ucell0 > 0;
m2 = Ucell1 > 0;
m3 = Ucell2 > 0;
plot(j(m1),Ucell0(m1), j(m2),Ucell1(m2), j(m3),Ucell2(m3))
.
5 Comments
More Answers (0)
See Also
Categories
Find more on Signal Generation and Preprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!