Keep getting an error message when integrating

1 view (last 30 days)
clear all, clc
T1=50+273.15; %%
T2=127+273.15; %%k
Fao=2.5; %%mol/min
P=10; %%atm
k1=10^-4; %%min^-1
R=8.314; %j/k*mol
R1=8.206*10^-5; %%atm*m^3/K*mol
E=85*1000; %%j/mol
k2=k1*exp(E/R*(1/T1-1/T2)); %%min^-1
cao=P/(T2*R1); %%mol/m^3
ep=2+1-1;
xf=.90;
fun=@(x) Fao/(cao*k2)*(1+ep*x)/(1-x);
vol=integral(fun,0,xf)
Error using integralCalc/finalInputChecks (line 526)
Output of the function must be the same size as the input. If FUN is an array-valued integrand, set the 'ArrayValued' option to
true.
Error in integralCalc/iterateScalarValued (line 315)
finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in Jallohw5p7a (line 15)
vol=integral(fun,0,xf)
I cant seem to integrate this function.

Accepted Answer

David Goodmanson
David Goodmanson on 19 Mar 2020
Hi Rodrigo,
try adding a dot to the function definition line, for element-by-element division:
fun=@(x) Fao/(cao*k2)*(1+ep*x)./(1-x);

More Answers (0)

Categories

Find more on Matrix Computations 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!