Integrating a multivariable function one variable at a time
Show older comments
I have a function which depends on x and y, f(x,y) (returns a scalar) and I need to integrate it so that for a particular point (x0,y0), I get a function p(theta), I basically convert it to polar, change the origin and integrate over r, so the remaining function only depends on theta:
%fun = @(x,y) Some function
fun = @(x,y) fun(x+x0,y+y0);
polarfun = @(r,theta) fun(r.*cos(theta),r.*sin(theta)).*r;
p = @(theta) integral(@(r)polarfun(r,theta),0,Inf);
After I get this function, I need to integrate it again (w.r.t theta). This doesn't work (a and b are the limits of the integral)
value = integral(p,a,b);
I need to set ArrayValued = true for it to work
value = integral(p,a,b,'ArrayValued',true);
I don't understand why I need to specify it's an ArrayValued function when it's not meant to be, also the integral takes much more time, and I need it to be calculated as fast as possible. Can you explain me why it is ArrayValued, and whether there is a way to make it without the ArrayValued set to true?
2 Comments
Torsten
on 14 Jul 2016
Is there anything that prevents you from using "integral2" ?
Take a look at the example
"Evaluate double integral in polar coordinates"
under
Best wishes
Torsten.
Pere Garau Burguera
on 14 Jul 2016
Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!