pl find a solution to integration in matlab

Respected Sir,
we are trying to execute the following code ..
function f=catalystweight(x)
T=630
K=exp((4596/T)-(3.822*log(T))+(0.002136*T)-(0.000000187*T*T)+12.44)
k2=(8.849*10e14)*exp(-20515.85/T);
N=4934;
H=14392;
A=800;
TM=21416;
FA0=4934;
PN2=((N-N*x)/(TM-2*N*x))*138;
PH2=((H-3*N*x)/(TM-2*N*x))*138;
PNH3=((A+2*N*x)/(TM-2*N*x))*138;
N=4934;
H=14392;
A=800;
TM=21416;
FA0=4934;
rN2=((k2*K*PN2*PH2)/((PNH3^0.5)*FA0)-(k2*PNH3)/(FA0*(PH2^1.5)))
f=FA0/rN2;
double e=int(f,x,0,0.1)
but matlab is displaying a warning message "explicit integral could not be found"
please help us solve the integration of f..
ramanayyah

Answers (2)

This has the appearance of a function for which there is no known explicit integral, and consequently you need to use numerical methods to solve it. This happens with a great many complicated integrals. Just call on the matlab function 'integral' as explained at:
http://www.mathworks.com/help/matlab/ref/integral.html
You are passing "x" in, but you are using x as if it is a symbolic variable in the int() call. If you are passing in a numeric value for then the f that is calculated is going to be a numeric value, and you would be trying to use a numeric value as the variable of integration. If you pass in a symbolic value for x then it can potentially work but only if it is a single symbolic variable name rather than a symbolic expression.
Do remember though that not every symbolic expression will have a closed form solution.
If you are hoping for a numeric approximation to the integral then you need to ask for that
double_e = feval(symengine, 'numeric::int', f, sym('x'), 0, 0.1)

Asked:

on 4 Apr 2014

Answered:

on 4 Apr 2014

Community Treasure Hunt

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

Start Hunting!