MATLAB: Have a question calculating integral

easyerrorfunctionintegral

hello guys.
I set up the functions and try to solve the integral but a error has occured.
my code :
syms L;
syms W;
syms a;
syms q;
syms n;
syms m;
syms R;
q = H./L;
a = W./q;
b = (W*(1-R)/(2*q));
m = (0.01*(81.0*W^2 + 180.0*b*W))/a;
n=sqrt(a*m+b^2)-m-b;
syms x;
f=sqrt(a*x+b^2)-x-b;
h=W*0.9-x;
m=(0.01*(80.1*W^2+180.0*b*W)/a);
n=sqrt(a*m+b^2)-m-b;
syms t;
f=@(x) sqrt(a*x+b^2)-x-b;
g=@(x,t) (sqrt(a*t+b^2)-t-b)/t*x;
p=@(x,t) ((sqrt(a*t+b^2)-t-b)-n)/(t-m)*(x-m)+n;
a=integral (f,0,m)-integral (g,0,t)-integral(p,t,m);
and here, I want to calculate the total integral, but some error has occured..
how do I solve it?
thank you.

Best Answer

You do not define H and you do not declare it symbolic.
You define g and p as function handles of two variables, but you pass them to integral() which expects a function handle of one variable to do a numeric integral of.
You try to integrate f to the upper limit m, but integral() is for numeric integrals and for numeric integrals you need numeric bounds.
Perhaps you want
a = int(f(x),x,0,m) - int(g(x,t),x,0,t) - int(p(x,t),x,t,m);
The result will be a piecewise() expression. It looks to me that is there due to the potential for a division by 0. For example your p(x,t) is undefined if L = 0 and we have no way to know that L is not permitted to be 0.