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);
  1 件のコメント
Rodrigo Blas
Rodrigo Blas 2020 年 3 月 19 日
Thank you! That worked

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by