Numerical calculation of the double integral

55 Views Asked by At

I need to calculate in Matlab the integral: $$ \eta(t) = \int_{0}^{\infty} \int_{0}^{2\pi}\sin(-\omega \cdot t) \cdot \sqrt{2 \cdot \frac{\pi c}{2 \omega^6} \cdot \exp \left(-\frac{4,575}{\omega^2 \cdot h^{0,8}} \right) \cdot \frac{2}{\pi} \cdot \cos^2(\psi)} \,d \omega \,d \psi.$$

where $h = 3.5; \; c = 3.05; \; t = 0, 0.1, ... , 30$

my attempts to do this

figure
t=0:0.1:40;
c=3.05;
h=3.5;
fun=@(omega,psi,c,h,t) sin(omega.*t).*sqrt(2*pi*c./(2.*omega.^6).*exp(-4.575./(omega.^2*h^0.8)).*2./pi.*cos(psi.^2));
q=integral2(@(omega,psi) fun(omega,psi,c,h,t),0,Inf, 0,2*pi,'ArrayValued',true);
plot(t,q)

but it doesn't work. Do I need to specify a calculation method?

1

There are 1 best solutions below

0
On BEST ANSWER

There is no ArrayValued option for integral2. You have to iterate manually:

t=0:0.1:30;
c=3.05;
h=3.5;
q= [];
fun=@(omega,psi,c,h,t) sin(omega.*t).*sqrt(2*pi*c./(2.*omega.^6).*exp...
    (-4.575./(omega.^2*h^0.8)).*2./pi.*cos(psi).^2); 
for ti= t
   q(end+1)=integral2(@(omega,psi) fun(omega,psi,c,h,ti),0,Inf, 0,2*pi,...
       'AbsTol',1e-4,'RelTol',1e-4);
end
plot(t,q)

Also, there was an error in your expression. cos(psi.^2) should be cos(psi).^2.