Solve triple integral of a function that upload its value every step

1 view (last 30 days)
I have to solve this TRIPLE integral:
P_4=integral3(fun_r,R1,R2,0,tau,z3,z4);
In order to solve this integral, it is NECESSARY to use a function handle.
So:
fun_r=@(R, theta, z) abs(Jr4)^2*R;
The problem is that fun_r depends on Jr4 but Jr4 uploads its value at each iteration, summing all the previous values (it is a summation).
If I consider Jr4 (computed only for the current iteration) and I put it immediately inside the brackets in fun_r, it works.
But I need to make the summation and in order to do so, I need to define Jr4 outside the function handle. But Jr4 depens on R,theta and z too. So I thought to do so:
syms z theta R
Xr4=A4d.*exp(gamma4.*z)+B4d.*exp(-gamma4.*z);
Jr4=real(Jr4+(real((Xr4.*(1./R).*besselj(np,alfak.*R).*exp(1i.*np.*(theta-OMEGA.*t))))));
fun_r=@(R, theta, z) abs(Jr4)^2*R;
P_4=integral3(fun_r,R1,R2,0,tau,z3,z4);
The error is:
Error using integral2Calc>integral2t/tensor (line 231)
Input function must return 'double' or 'single' values. Found 'sym'.
Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in integral2Calc (line 9)
[q,errbnd] = integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral3/innerintegral (line 137)
Q1 = integral2Calc( ...
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral3 (line 121)
Q = integralCalc(@innerintegral,xmin,xmax,integralOptions);
Error in Untitled5 (line 91)
P_4=integral3(fun_r,R1,R2,0,tau,z3,z4);
  • Is it possible to overcome this problem?
Please help me.
  11 Comments
Luigi Stragapede
Luigi Stragapede on 17 Jul 2020
thanks a lot guys. How can I help you? Could I give you points for giving me answers?
Walter Roberson
Walter Roberson on 17 Jul 2020
Right at the moment, there is a problem with the Answers facility and we cannot repost our comments as Answers. That will probably be fixed in a few hours.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!