Dear friends, my question is How to do numerical multiple integral (more than triple) by using matlab?
For example, I have a function,Y = Func. It has 5 var. Hence, Y= func(a,b,c,d,e). If I want to do the integration with respect to a,b,c,d,e. (var a is the first one, e is the last one.) And region of a = [0 ,b] (this is a function handle), b = [0,c], c= [0.d], d= [0,e], e=[0, Inf].
Now, here is my 'real' question. the code is below
%%%==== just some parameters ====
a=4;la1=1/(pi*500^2); la2= la1*5;p1=25; p2=p1/25;sgma2=10^(-11);index=1;g=2./a;syms r u1 u2 u3 u4 u5index = -2; powe= index ; seta= 10^powe; xNor = ( (u5./u1).^(a./2)+ (u5./u2).^(a./2) + (u5./u3).^(a./2)+ (u5./u4).^(a./2) + 1 ).^(2./a); x = (xNor).^(0.5) * seta^(-1/a); q=pi.*(la1.*p1.^(2./a)+la2.*p2.^(2./a));%%%==== parameters end ====
fun1 = r./(1+ r.^a ); out1 = int(fun1, x, Inf) ; out1fcn = matlabFunction(out1); %%===Convert symbolicto function handle
y = @(u5,u4,u3,u2,u1) exp(-u3.*(1+2.*... %%<== in method 3, replace as 'y= exp(-u3.*(1+2.*...' ( out1fcn )./... %%<== in method 3, replace as '( out1 )./...' ( (( (u5./u1).^(a./2)+ (u5./u2).^(a./2) + (u5./u3).^(a./2)+ (u5./u4).^(a./2) + 1 ).^(2./a)).*seta.^(-2./a)))).*... exp(-sgma2.*q.^(-a./2).* seta.*u3.^(a./2)./... ((( (u5./u1).^(a./2)+ (u5./u2).^(a./2) + (u5./u3).^(a./2)+ (u5./u4).^(a./2) + 1 ).^(2./a)).^(a./2)) );%%%=== method 1, not working ============ upper ,lower bound should be a number
% y1 = integral( y ,0,@(u2) u2);
% y2 = integral( y1 ,0,@(u3) u3);
% y3 = integral( y2 ,0,@(u4) u4);
% y4 = integral( y3 ,0, Inf);
%%%=== method 2, not working, y1 is already wrong ===============
%%%Undefined function 'minus' for input arguments of type 'function_handle'.
% y1 = quad( y ,0,@(u2) u2);
% y2 = quad( y1 ,0,@(u3) u3);
% y3 = quad( y2 ,0,@(u4) u4);
% y4 = quad( y3 ,0, Inf);
%%%=== method 3. not working, DOUBLE cannot convert the input expression into a double array. ==============
% y1 = int( y ,0,@(u2) u2);
% y2 = int( y1 ,0,@(u3) u3);
% y3 = int( y2 ,0,@(u4) u4);
% y4 = int( y3 ,0, Inf);
% y5 = double(y4)
Dear guys. could you copy the code to your matlab and take a look for me. Thank you so much for your time.
Thank you.
Best Answer