MATLAB: How to integrate a functional of integrals numerically

numerical integration

Greetings, Trying to numerically integrate the following http://www.scribd.com/doc/221721132/Numerical-Integration expression> using MATLAB. The answer should be a table of phi as a function of j (rows) and x (columns) as indicated on the attached file. Any help is appreciated. Thanks Naeem

Best Answer

The integrals in the numerator and denominator of φ(z,j) are actually double integrals of ψ w.r.t. x and y, so I calculated them that way in the loop, substituting in the required values for z, and then computed φ(z,j) from them and beta. (The entire calculation required about 214 seconds on my machine.)
This code:
zv = 0.1:0.1:1;
jv = 0:31;
fpsixyz = @(x,y,z) exp(-(((x-y).*z).^2)/4)./(1+y.^2); % Function to integrate
B = @(j) 1E-5 * 2.^j; % Beta
for k1 = 1:size(jv,2)
for k2 = 1:size(zv,2)
z = zv(k2);
psiz = integral2(@(x,y) fpsixyz(x,y,z), 0, Inf, -Inf, Inf); % Integrate over [x,y]
j = jv(k1);
phizj(k1,k2) = psiz ./ (B(j) + psiz); % Compute phi(z,j)
end
end
figure(1)
surfc(phizj)
xlabel('\itz\rm')
ylabel('\itj\rm')
zlabel('\phi(\itz, j\rm)')
set(gca, 'XTick', 1:2:10, 'XTickLabel', zv(1:2:end))
axis([xlim 0 31 0 1])
produces: