Keep getting an error message when integrating

조회 수: 2 (최근 30일)
Rodrigo Blas
Rodrigo Blas 2020년 3월 19일
댓글: Rodrigo Blas 2020년 3월 19일
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.

채택된 답변

David Goodmanson
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 CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by