Nested integral within integral2 in matlab -
i'm attempting take double integral (using integral2) of function defined integral.
http://i.imgur.com/giuslsw.jpg
here 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)); i=2:length(t) j=i:length(t) a(i,j)=integral2(fun,t(i-1),t(i),t(j-1),t(j)); end end
i'm receiving error
error using integral (line 86) , b must floating point scalars.
can provide information on how fix problem.
here go:
l=3; t=linspace(0,1,365); fun3= @(v) integral(@(v)exp(.071*v),0,v,'arrayvalued',true); i=2:length(t) 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, slow.
Comments
Post a Comment