double integral with one changing limits integral

Hi experts,
I am trying to numerically calculate a double integral with one changing limits integral. f(x,a,b), g(y,a,b) are the functions, a and b are parameters. the integral is: h(a,b) = int [0,b/a] ( f * {int [0,x] (g*dy)} * dx). Give the value of a, I want to solve the value of b with h(a,b) = 1.
I tried to use function handles and quad() and fsolve(), there is always error saying the fsolve() cannot initiate the integration. Does anyone can help me solve this problem?
Here is my code which does not work (just a simplified version):
function test
f = @(x,a,b) sin(a*x+b);
g = @(y,a,b) quad(@(x) f(x,a,b),0,y);
h = @(a,b) quad(@(y) cos(y)*g(y,a,b),0,2);
for b=1:1:3
n =@(a) h(a,b);
fsolve(n,1)
end
Thanks!!

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 6월 13일

0 개 추천

Try this is code:
f = @(x,a,b) sin(a*x+b);
g = @(y,a,b) arrayfun(@(z)quad(@(x) f(x,a,b),0,z),y);
h = @(a,b) quad(@(y) cos(y).*g(y,a,b),0,2);
out = arrayfun(@(c)fzero(@(a)h(a,c),1),1:3);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

질문:

2012년 6월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by