Solve triple integral of a function that upload its value every step
2 次查看(过去 30 天)
显示 更早的评论
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?
- Using THREE times the function 'q = integral(fun,xmin,xmax)', can be a solution?
Please help me.
11 个评论
Walter Roberson
2020-7-17
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Computations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!