Why does it give me errors during numerical integration?

1 view (last 30 days)
Greetings,
When I run the following code for a numerical integration:
T = @(x) T0 + (-Hrxn)./(CpSum).*x;
K = @(x) K0.*exp(-E0./(R.*T));
Keq = @(x) exp(-4.33+4577.9./T);
yA = @(x) FA0./FT.*(1-x);
yB = @(x) FB0./FT.*(thetaB-x);
yC = @(x) FC0./FT.*(thetaC+x);
yD = @(x) FD0./FT.*(thetaD+x);
rA = @(x) K.*(yA.*yB-yC.*yD./Keq);
V = integral(@(x) FA0./rA,0,0.493647527)
it shows the following error:
I believe it has to do with the function handle or operators, but I could not figure it out.

Accepted Answer

Torsten
Torsten on 29 Mar 2023
T0=1;Hrxn=1;CpSum=1;K0=1;E0=1;R=1;FA0=1;FB0=1;FC0=1;FD0=1;thetaB=1;thetaC=1;thetaD=1;FT=1;
T = @(x) T0 + (-Hrxn)./(CpSum).*x;
K = @(x) K0.*exp(-E0./(R.*T(x)));
Keq = @(x) exp(-4.33+4577.9./T(x));
yA = @(x) FA0./FT.*(1-x);
yB = @(x) FB0./FT.*(thetaB-x);
yC = @(x) FC0./FT.*(thetaC+x);
yD = @(x) FD0./FT.*(thetaD+x);
rA = @(x) K(x).*(yA(x).*yB(x)-yC(x).*yD(x)./Keq(x));
V = integral(@(x) FA0./rA(x),0,0.493647527)
V = 4.4877

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!