Integrating a multivariable function one variable at a time
显示 更早的评论
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 个评论
Torsten
2016-7-14
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
2016-7-14
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!