You are on page 1of 2

G=6.

67*10^(-3);
gamma=2*G;
h1=2000;
h2=3000;
d=3000;

%gravity constant Nm^2kg^-2


% depth of upper side (m)
% depth of bottom side(m)
% wide (m)

rho1=2.700;
rho2=2.000;
%deltarho=abs(rho2-rho1);
deltarho=abs(rho1-rho2);

%dolomite density g/cm^3


%sand density
g/cm^3

x=-10000:50:10000;
[rowx,colx]=size(x);
%data analitik (model kotak)
for j=1:colx
ginit(1,j)=gamma*deltarho*d*log10((h2^2+(x(1,j)).^2)./(h1^2+(x(1,j)).^2));
%ginit(1,j)=gamma*deltarho*d*log10((1+((h2^2)/(x(1,j))^2))/(1+((h1^2)/(x(1,j
))^2))));
end
%data observasi (data analitik + noise)
for k=1:colx
noise(1,k)=0.5*ginit(1,k);
%noise 10%
gobs(1,k)=(ginit(1,k)-noise(1,k))+2*noise(1,k)*rand(1);
%gobs(1,k)=(ginit(1,k)-noise(1,k)*rand(1));
%gobs(1,k)=(ginit(1,k)-ginit(1,k)*noise(1,k)*rand(1));
end
%initial model
rhop=1.2;
%initial prediction of density contrast
dinv=2000;
%initial prediction of wide of square
h1p=2000;
%depth constant h1 (meter)
h2p=3000;
%depth constant h2 (meter)
rhoinv=rhop;
dp=3000;
disp(['d_initial = ' , num2str(dinv)]);
disp(['rho_initial = ' , num2str(rhoinv)]);
%the initial data of the model
for l=1:colx
gp(1,l)=gamma*rhop*dp*log10((h2p^2+(x(1,l)).^2)./(h1p^2+(x(1,l)).^2));
%gp(1,l)=(gamma*rhop*d*log10((1+((h2p^2)/(x(1,l))^2))/(1+((h1p^2)/(x(1,l))^2
))));
end
%calculation of error
deltag=gobs-gp;
%error=deltag*deltag';
error=(deltag.^2);
%The Linearized Inversion Method
iteration=0;
while error>=0.001
for m=1:colx
gi(1,m)=gamma*rhop*dp*log10((h2p^2+(x(1,m)).^2)./(h1p^2+(x(1,m)).^2));

%gi(1,l)=(gamma*rhop*d*log10((1+((h2p^2)/(x(1,m))^2))/(1+((h1p^2)/(x(1,m))^2
))));
rhoget(1,m)=gi(1,m)./(gamma*dp*log10((h2p^2+(x(1,m)).^2)./(h1p^2+(x(1,m)).^2
)));
dget(1,m)=gi(1,m)./(gamma*rhop*log10((h2p^2+(x(1,m)).^2)./(h1p^2+(x(1,m)).^2
)));
end
%local error
deltag=gobs-gi;
%error=deltag*deltag';
error= (deltag.^2);
%a = length(gi);
%y = 0;
%for z=1:colx
%
deltag(1,z)= (((gi(1,z) - gobs(1,z))/ gi(1,z)))^2;
%
y = y+deltag;
%end
%y = y/a;
%y = sqrt(y);
%jacobian matriks
for n=1:j
%turunan parsial terhadap delta_rho
A(1,n)=gamma*dp*log10((h2p^2+(x(1,n)).^2)./(h1p^2+(x(1,n)).^2));
%turunan parsial terhadap d (lebar)
A(2,n)=gamma*rhop*log10((h2p^2+(x(1,n)).^2)./(h1p^2+(x(1,n)).^2));
end
%AA=inv(A*A');
deltamod=(A*deltag')\(A*A');
%deltamod=(deltag*A')\(A*A');
rhopn=rhop+deltamod(1,1);
dpn=dp+deltamod(1,2);
rhop=rhopn;
dp=dpn;
iteration=iteration+1;
end
rho_inv=rhoinv+deltamod(1,1);
d_inv=dinv+deltamod(1,2);
rho_inversion=rhoget(1,1);
d_inversion=dget(1,1);
disp(['d_inversion = ' , num2str(d_inversion)]);
disp(['rho_inversion = ' , num2str(rho_inversion)]);
disp(['jumlah iterasi = ' , num2str(iteration)]);
plot(x,ginit,'-b');
hold on;
plot(x,gobs,'-g');
hold on;
plot(x,gi,'r');

You might also like