error message when trying ot integrate

2 vues (au cours des 30 derniers jours)
Rodrigo Blas
Rodrigo Blas le 23 Avr 2020
Commenté : Rodrigo Blas le 23 Avr 2020
To = 27 + 273.15; % C
vo = 2; % dm^3/s
cao = 0.1; % mol/dm^3
k1 = .01; % dm^3/mol*s
tha = 1;
thb = 1;
ha = -20000; hb=-15000; hc=-41000; % cal/mol
cpc = 30;cpa=15;cpb=15; % cal/mol*k
sumtcp = tha*cpa+thb*cpb;
delcp = cpc-cpb-cpa;
dhrx = hc-hb-ha;
E = 10000; % cal/mol
R = 1.987; % cal/mol*k
x1 = .85;
ca = cao*(1-x);
cb = cao*(1-x);
cc = cao*x;
fao = cao*vo;
%%CSTR VOLUME
T = To+(-dhrx)*x/((sumtcp)+delcp*x) ;
k = k1*exp(E/R*(1/To-1/T));
ra = -(k*(cao)^2*(1-x)^2);
vcstr = fao*x/(-ra);
%%PFR Vol
fun = @(x) fao/(-ra);
>> vpfr=integral(fun,0,x1)
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);
>>
I keep getting this error message. Not sure how to fix
  12 commentaires
darova
darova le 23 Avr 2020
Everywhere should be @(x)
Rodrigo Blas
Rodrigo Blas le 23 Avr 2020
To=27+273.15; %%C
vo=2; %%dm^3/s
cao=0.1; %%mol/dm^3
k1=.01; %%dm^3/mol*s
tha=1;thb=1;
ha=-20000; hb=-15000; hc=-41000; %%cal/mol
cpc=30;cpa=15;cpb=15; %%cal/mol*k
sumtcp=tha*cpa+thb*cpb;
delcp=cpc-cpb-cpa;
dhrx=hc-hb-ha;
E=10000; %%cal/mol
R=1.987; %%cal/mol*k
x1=0.85;
ca=@(x) cao*(1-x);
cb=@(x) cao*(1-x);
cc=cao*x;
fao=cao*vo;
%%CSTR VOLUME
T=@(x) To+(-dhrx)*x/(sumtcp+delcp*x) ;
k=@(x) k1*exp(E/R*(1/To-1/T));
ra=@(x) -(k*ca*cb);
%%vcstr=fao*x/(-ra);%%
%%PFR Vol
f=@(x) fao./(-ra(x));
vpfr=integral(f,0,x1);
>> Jallohw9p6
Undefined operator '*' for input arguments of type
'function_handle'.
Error in Jallohw9p6>@(x)-(k*ca*cb)
Maybe make the part I want to integrate into a seperate function?
Would that be easier?

Connectez-vous pour commenter.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 23 Avr 2020
Try this code and compare it with your code to see the issues.
To=27+273.15; %%C
vo=2; %%dm^3/s
cao=0.1; %%mol/dm^3
k1=.01; %%dm^3/mol*s
tha=1;thb=1;
ha=-20000; hb=-15000; hc=-41000; %%cal/mol
cpc=30;cpa=15;cpb=15; %%cal/mol*k
sumtcp=tha*cpa+thb*cpb;
delcp=cpc-cpb-cpa;
dhrx=hc-hb-ha;
E=10000; %%cal/mol
R=1.987; %%cal/mol*k
x1=0.85;
ca=@(x) cao*(1-x);
cb=@(x) cao*(1-x);
% cc=cao*x;
fao=cao*vo;
%%CSTR VOLUME
T=@(x) To+(-dhrx)*x/(sumtcp+delcp*x) ;
k=@(x) k1*exp(E/R*(1/To-1/T(x)));
ra=@(x) -(k(x).*ca(x).*cb(x));
%%vcstr=fao*x/(-ra);%%
%%PFR Vol
f=@(x) fao./(-ra(x));
vpfr=integral(f,0,x1);

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Computations dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by