Keep getting an error message when integrating
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
David Goodmanson
2020-3-19
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Computations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!