Optimized solution for a function with two integrals which depend on each other
Mostrar comentarios más antiguos
Hi everyone,
I have already created a code which numerically calculates the following function:

As you can see the inner integral depends on the outer one via 'q'. The inner integral is solved with the integral command
G_inner_integral = integral (@(y) inner_function(y),0,2*pi,'ArrayValued',true);
for every iteration inside a for loop, in which via trapezoidal rule the outer integral and therefore the whole function is approximated.
Is it possible to discard the for loop and solve it in a more clever way, maybe even within a few commands (with the help of functions like cumtrapz, trapz, or integral)? I have tried a some of those approaches but with no desired result.
P.S Prefer the numerical solution as the functions inside the integrals are quite complex and therefore time consuming for any analytical approach.
Thank you in advance
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Numerical Integration and Differentiation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

