Borrar filtros
Borrar filtros

Multiple function calls requiring vectorised expressions.

1 visualización (últimos 30 días)
Henrik Dam
Henrik Dam el 22 de Sept. de 2014
Respondida: Sean de Wolski el 22 de Sept. de 2014
This is an example of a problem which arose for me today. I found an ugly workaround in my specific case, but I would like to know if there is some general good way of handling the problem. So I tried to make an example which is cleaner so I hope makes more sense.
Assume I have some function f(x,y,z), I want to define g(x,y)=int_a^b f(x,y,z) dz, and h(x)=int_p^q g(x,y) dy, which can not be done analytically. I want the integrals to be evaluated numerically, which is easily achieved at the first level by using the Integral function.
This requires the function to accept vector values in z, but for the next level it requires simultaneously to accept vector values in y. This does not seem achievable in general since the vectors can be of different length. Is there a nice trick or does one need to find a specific work around depending on the case, i.e. here defining it using integral2.

Respuestas (1)

Sean de Wolski
Sean de Wolski el 22 de Sept. de 2014
It sounds like you might be able to use bsxfun to apply the operation to the two separate dimensions. Consider:
>> bsxfun(@plus,1:3,(1:2).')
If you write what you have above in code it might help us further understand it.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by