You are on page 1of 1

syms x1 x2

x=[x1 x2];
mu=[1 2];
sigma=[2 1;1 2];
fx1x2=inline(mvnpdf(x,mu,sigma));
a= input ('a:');
b= input ('b:');
c= input ('c:');
d= input ('d:');
nx1=input('nx1:');
nx2=input('nx2:');
hx1=(d-c)/nx1;
hx2=(b-a)/nx2;
j=0;
while a<=b
j=j+1;
hasil1=0;
hasil2=0;
for i=1:nx1-1
if mod(i,2)==0
hasil1=hasil1+2*fx1x2(c+i*hx1,a);
else
hasil2=hasil2+4*fx1x2(c+i*hx1,a);
end
end
luas(j)=hx1/3*(fx1x2(c,a)+2*hasil1+4*hasil2+fx1x2(d,a));
a=a+hx2;
end
hasil3=0;
hasil4=0;
for i=2:j-1;
if mod((i-1),3)==0
hasil3=hasil3+2*luas(i);
else
hasil4=hasil4+3*luas(i);
end
end
biv=hx2/8*3*(luas(1)+2*hasil3+3*hasil4+luas(j));
disp(biv);

You might also like