You are on page 1of 4

Satya Permana Yoga P

03411540000042

1. Seismik refleksi
clear all
clc
%data observasi
x=[60 80 100 120 140 160 180 200 220 240 260 280 300];
t=[0.5147 0.5151 0.5155 0.5161 0.5167 0.5175 0.5183 0.5192 0.5202 0.5209
0.5216 0.5222 0.5229];
t2=t.^2;
%plot grafik
plot(x,t,'*r');
grid;
xlabel('offset');
ylabel('travel time');
title('nilai variasi kecepatan terhadap waktu dan offset');
%membuat matrik kernel
n=length(x);
for k=1:n
G(k,1)=1;
G(k,2)=x(k);
G(k,3)=x(k)^2;
end
%inversi least square
m=inv(G'*G)*G'*t2';
hold on;
%plot garis (least-square)
t2_invers=m(1)+m(2)*x+m(3)*x.^2;
v=sqrt(1/m(3))
z=sqrt((m(1)*v^2)/4)
sinalfa=((m(2)*v^2)/(4*z))
sudut = asind (sinalfa)

plot(x,t2_invers,'linewidth',1);
legend('observations','calculations');
%eror least square
t_error=(t2_invers - t2).^2;
t_error_sum=sum(t_error);
E=sqrt(1/n*t_error_sum)
Satya Permana Yoga P
03411540000042

2. Model Bidang
clc
clear

% Data observasi
x = [2 5 7 4 1 3 6 9 8 4];
y = [3 6 2 7 8 9 4 1 5 5];
z = [10.6 23.5 27.3 20.8 11.1 18.9 25.4 33.5 33.2 24.1]

% Plot data observasi


plot3(x,y,z, '*r');
grid;
xlabel('Jarak x (m)');
ylabel('Jarak y (Celcius)');
zlabel('Nilai z');
title('\fontsize{14} Model Bidang');

% Membentuk matrik kernel G dan vektor d


n = length(z);
for k = 1:n
G(k,1) = 1; %matriks G kolom 1 bernilai 1 semua
G(k,2) = x(k); %matriks G kolom 2 bernilai x
G(k,3) = y(k); %matriks G kolom 3 bernilai y
end
d = z';

% Perhitungan inversi dengan general least-squares


m = inv(G'*G)*G'*d;

% Plot hasil inversi (berupa garis least-squares)


hold on;
[X,Y] = meshgrid(min(x):max(y),min(y):max(y));
z_invers = m(1) + m(2)*X + m(3)*Y;
surf(X,Y,z_invers);
grid on
Satya Permana Yoga P
03411540000042

3. Perbandingan menggunakan polyfit dan metode inversi least square


Menggunakan Polyfit
clear all
clc
%data observasi
x=[60 80 100 120 140 160 180 200];
t=[0.5147 0.5151 0.5155 0.5161 0.5167 0.5175 0.5183 0.5192];
t2=t.^2;
%plot grafik
plot(x,t,'*r');
grid;
xlabel('offset');
ylabel('travel time');
title('nilai variasi kecepatan terhadap waktu dan offset');
%membuat matrik kernel
n=length(x);
for k=1:n

G(k,1)=x(k)^2;
end
%inversi least square
m=polyfit(G,t2',1);
hold on;
%plot garis (least-square)
t2_invers=m(2)+m(1)*x.^2;
v=sqrt(1/m(1))
z=0.5*sqrt(m(2)/m(1))
plot(x,t2_invers,'linewidth',1);
legend('observations','calculations');
%eror least square
t_error=(t2_invers - t2).^2;
t_error_sum=sum(t_error);
E=sqrt(1/n*t_error_sum)
Satya Permana Yoga P
03411540000042

Tidak Menggunakan polyfit


clear all
clc
%data observasi
x=[60 80 100 120 140 160 180 200];
t=[0.5147 0.5151 0.5155 0.5161 0.5167 0.5175 0.5183 0.5192];
t2=t.^2;
%plot grafik
plot(x,t,'*r');
grid;
xlabel('offset');
ylabel('travel time');
title('nilai variasi kecepatan terhadap waktu dan offset');
%membuat matrik kernel
n=length(x);
for k=1:n
G(k,1)=1;
G(k,2)=x(k)^2;
end
%inversi least square
m=inv(G'*G)*G'*t2';
hold on;
%plot garis (least-square)
t2_invers=m(1)+m(2)*x.^2;
v=sqrt(1/m(2))
z=0.5*sqrt(m(1)/m(2))
plot(x,t2_invers,'linewidth',1);
legend('observations','calculations');
%eror least square
t_error=(t2_invers - t2).^2;
t_error_sum=sum(t_error);
E=sqrt(1/n*t_error_sum)

Related Interests