Multiple integrals with limits as variables

2 visualizaciones (últimos 30 días)
Mauricio
Mauricio el 16 de Sept. de 2014
Comentada: Mauricio el 18 de Sept. de 2014
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

Respuesta aceptada

Mike Hosea
Mike Hosea el 16 de Sept. de 2014
Editada: Mike Hosea el 16 de Sept. de 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);
  1 comentario
Mauricio
Mauricio el 18 de Sept. de 2014
Thanks for your helped... It just worked fine.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by