필터 지우기
필터 지우기

Multiple function calls requiring vectorised expressions.

조회 수: 1 (최근 30일)
Henrik Dam
Henrik Dam 2014년 9월 22일
답변: Sean de Wolski 2014년 9월 22일
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.

답변 (1개)

Sean de Wolski
Sean de Wolski 2014년 9월 22일
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.

카테고리

Help CenterFile Exchange에서 Application Deployment에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by