Nested integral within integral2 in matlab

守給你的承諾、 提交于 2019-12-08 05:00:46

问题


I'm attempting to take the double integral (using integral2) of a function that is defined by an integral.

http://i.imgur.com/gIUsLSw.jpg

Here is what I am currently attempting:

t=linspace(0,1,50);
fun_1= @(v) exp(.071*v)
fun  = @(x,y) exp(0.14*0.00607*integral(@(u)fun_1(u),0,x)).*exp(-(x-y).^2).*exp(0.14*0.00607*integral(@(u)fun_1(u),0,x));
for i=2:length(t)
    for j=i:length(t)
    A(i,j)=integral2(fun,t(i-1),t(i),t(j-1),t(j));
    end
end

I'm receiving the error

Error using integral (line 86) A and B must be floating point scalars.

Can anyone provide any information on how to fix this problem.


回答1:


Here you go:

l=3;
t=linspace(0,1,365);
fun3= @(v) integral(@(v)exp(.071*v),0,v,'ArrayValued',true);
for i=2:length(t)
  for j=i:length(t)
      xx=t(i);
      yy=t(j);
      fun  = @(x,y) exp(0.14*0.00607*fun3(yy)).*exp(-(x-y).^2/l).*exp(0.14*0.00607*fun3(xx));
      y(i,j)=integral2(fun,t(i-1),t(i),t(j-1),t(j));
  end
end

It works, but it is very slow.



来源:https://stackoverflow.com/questions/18407385/nested-integral-within-integral2-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!