Anda di halaman 1dari 2

%Rexha Verdhora Ry

%Geophysical Engineering
close all
clear,clc
file=['slice'];
i=1; ni=1;

while i<=ni
dataraw=load([file num2str(i) '.dat']);
data=[dataraw(:,4) dataraw(:,3)];

%Merubah spasi
ds=500;
sb=[0:ds:max(data(:,1))]'; %spasi baru
cb=interp1(data(:,1),data(:,2),sb); %CBA pada spasi baru

%menyimpan data
l=[sb cb];
save([file num2str(i) '_spasibaru.dat'],'l','-ascii');

%fft
ft=fft(cb,length(cb))*ds;
%mengambil setengah data pertama karena sifat pencerminan
w=ft(1:round(length(ft)/2));
A=abs(w);
lnA=log(A);

f = [linspace(0,1,length(A))/(ds.*2)]'; % frekuensi

kf=2*pi*f;

%menyimpan hasil
h=[A lnA f];
save([file num2str(i) '_spektrum.dat'],'h','-ascii');

%plot data
figure(i)
plot(kf, lnA, 'ko','MarkerFaceColor','b');
hold on;
set(gcf,'color','white');
set(gca,'color',[1 1 1],'fontsize',14);
fr=['Matriks ' num2str(i)];
xlabel('k (cycle/meter)','fontweight','bold');
ylabel('Ln Spektrum','fontweight','bold');grid on;

%mencari posisi batas bawah untuk regional


%Rexha Verdhora Ry
%Geophysical Engineering
[px py]=ginput(1);
err=100;
for j=1:length(kf)
er=sqrt((px-kf(j))^2+(py-lnA(j))^2*px/py);
if er<err
err=er;
bb=j;
end
end
%batas atas & bawah
ba=2;
reg=polyfit((kf(ba:bb)),(lnA(ba:bb)),1);
re1=polyval(reg, kf(ba:bb));
plot(kf(ba:bb),re1, 'g');
text(kf(ba),lnA(ba),[num2str(reg(1)) 'x + ' num2str(reg(2))],...
'VerticalAlignment','Bottom')

%mencari posisi batas bawah untuk residual


[px py]=ginput(1);
err=100;
for j=bb+1:length(kf)
er=sqrt((px-kf(j))^2+(py-lnA(j))^2*px/py);
if er<err
err=er;
bc=j;
end
end
%batas atas & bawah
res=polyfit((kf(bb+1:bc)),(lnA(bb+1:bc)),1);
re2=polyval(res, kf(bb+1:bc));
plot(kf(bb+1:bc),re2, 'r');
text(kf(bc),lnA(bc),[num2str(res(1)) 'x + ' num2str(res(2))],...
'VerticalAlignment','Bottom')

Window(i)=2*pi/(100*(res(2)-reg(2))/(reg(1)-res(1)));
title(['Window = ' num2str(Window(i))],'fontweight','bold','fontsize',14);
hold off

name=input('Apakah oke? (1=Oke, 2=Belum): ');


if name==1
i=i+1;
end

end

WindowFix=mean(Window)

Anda mungkin juga menyukai