Multiple integrals with limits as variables
2 views (last 30 days)
Show older comments
I have the function f(z,w,l) and I want to obtain a function g(z) by integrating f(z,w, l) as follows: I need to integrate f for 0 < l < w and then perform the integral for 0 < w < L; where L is a constant. Note that w is a variable while L is a number. I would appreciate any suggestions. Thanks
0 Comments
Accepted Answer
Mike Hosea
on 16 Sep 2014
Edited: Mike Hosea
on 16 Sep 2014
function_of_scalar_z_only = @(z)integral2(@(w,l)f(z,w,l),0,L,0,@(w)w);
g = @(z)arrayfun(function_of_scalar_z_only,z);
Depending on how f is written, you may need to manually expand the scalar z.
function_of_scalar_z_only = @(z)integral(@(w,l)f(z*ones(size(w)),w,l),0,L,0,@(w)w);
g = @(z)arrayfun(function_of_scalar_z_only,z);
As the long function name suggests, that first function is only good for a scalar input. The ARRAYFUN modification "vectorizes" it so you can do all the usual things with g that you want, e.g. things like
x = linspace(zmin,zmax);
y = g(x);
plot(x,y);
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!