R1a116005.docx

  • Uploaded by: David Satria
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View R1a116005.docx as PDF for free.

More details

  • Words: 2,485
  • Pages: 20
Nama : David Satria Nim

: R1A116005

TUGAS 02 PENGOLAHAN SINYAL GEOFISIKA

1. Buatlah suatu Algoritma Disrete Fourier Transform (DFT) dengan implementasi Bahasa pemrograman Matlab. Gambar 1.1 berikut ini memperlihatkan bentuk function dari algoritma Disrete Fourier Transform function Xk=dft(xn) [N,M]=size(xn); if M~=1, % Pastikan bahwa xn merupakan vektor kolom xn=xn'; N=M; end Xk=zeros(N,1); n=0:N-1 for k=0:N-1 Xk(k+1)=exp(-j*2*pi*k*n/N)*xt; end % end of function % Credit by: La Hamimu @2005

Gambar 1.1 Bentuk fungsi algoritma Disrete Fourier Transform (DFT)

Melihat gambardiatas dapat dijelaskan menjadi:

Algoritma dari program DFT diatas yaitu :  mulai  Mendeklarasikan suatu fungsi transformasi fourier diskrit sebagai Xk=dft(xn)  Membuat vektor kolom (N) sepanjang xn  Membuat keputusan jika M tidak sama dengan 1, maka xn=xn’ dan N=M  Membuat vector kolom Xk menjadi vector kolom nol dengan fungsi zeros(N,1)  Memasukan nilai n dari 0 sampai N-1  Melakukan perulangan untuk k sama dengan 0 sampai dengan N-1  Menghitung nilai xk(k+1)= e  selesai

− j 2 πkn N

xt

2. Buatlah Algoritma Invers Disrete Fourier Transform (IDFT) dengan implementasi Bahasa pemrograman MATLAB, Gambar 2.1 di bawah ini akan diperlihatkan bentuk function dari algoritma IDFT : % Invers Discrete Fourier Transform [IDFT] % =============================== function xn=idft(Xk) [N,M]=size(Xk); if M~=1, % Pastikan Xf merupakan vektor kolom Xk=Xk’;N=M; end xn=zeros(N,1); k=0:N-1 for n=0:N-1 xn(n+1)=exp(j*2*pi*k*n/N)*Xk; end xn=xn/N; % end of function % Created by: La Hamimu @2004

Gambar 2.1 Bentuk fungsi dari Algoritma Invers Disrete Fourier Transform (IDFT)

Penguraian nya:

Algritma dari suatu program IDFT diatas yaitu:  Mulai  Mendeklarasikan Fungsi Invers Discrete Fourier Transform Sebagai Xn=Idft(Xk)  Membuat Vector Kolom N Sepanjang Xk  Membuat Keputusan Jika M Tidak Sama Dengan 1, Maka Xk=Xk’ Dan N=M  Membuat Vector Kolom Xn Menjadi Vector Kolom Nol Dengan Fungsi Zeros(N,1)  Memasukan Nilai K Sama Dengan 0 Sampai Dengan N-1  Melakukan Perulangan Untuk N Sama Dengan 0 Sampai Dengan N-1 j 2 πkn

 Menghitung Nilai Xn(N+1)= e N Xk  Kembalikan Nilai Hasil Perhitungan Xk Ke Skrip Awal  Selesai

3. Hitunglah DFT untuk 4 titik data dari signal berikut ini dengan menggunakan koordinat kartesian, dimana diketahui jika �<0 dan �≥4 maka �(�)=0: a) x(0) = 1, x(1) = 0, x(2) = -1, x(3) = 0 b) x(0) = 1, x(1) = 0, x(2) = -1, x(3) = -1 c) x(0) = -1, x(1) = 1, x(2) = 1, x(3) = 1

d) x(0) = -1, x(1) = 0, x(2) = 1, x(3) = 2

e) x(0) = -1, x(1) = -1, x(2) = 1, x(3) = -1 a) Untuk k=0 N −1

Xk=

∑ X (n)e

Jawab :

− j 2 πkn N

n=0

3

X(0)=

− j 2 π∗0∗n 4

∑ X (n) e n=0

X(0)= X (0) e X (3) e

− j 2 π∗0∗0 4

+ X (1) e

− j 2 π∗0∗3 4

− j 2 π∗0∗1 4

+ X (2) e

− j 2 π∗0∗2 4

X(0)= (1* e 0 )+(0* e 0 )+(-1* e 0 )+(0* e 0 ) X(0)=(1*1)+(0*1)+(-1*1)+(0*1) X(0)=1+0-1+0 X(0)=0  Untuk K=1 3

X(1)=

− j 2 π∗1∗n 4

∑ X (n)e n=0

X(1)= X ( 0)e X (3) e

+

− j 2 π∗1∗0 4

− j 2 π∗1∗3 4

+ X (1) e

− j 2 π∗1∗1 4

+ X (2) e

− j 2 π∗1∗2 4

+

X(1)= (1* e 0 )+(0* e−1.57 j )+(-1* e−3.14 j )+(0* e−4.71 j ) X(1)=(1*1)+(0*-1j)+(-1*-1)+(0*1j) X(1)= 1+0+1+0 X(1)=2

 Untuk K=2 3

X(2)=

∑ X (n) e n=0

X(2)= X (0) e X (3)e

− j 2 π∗2∗n 4

− j 2 π∗2∗0 4

− j 2 π∗2∗3 4

+ X (1)e

− j 2 π∗2∗1 4

+ X (2) e

− j 2 π∗2∗2 4

+

X(2)= (1* e 0 )+(0* e−3.14 j )+(-1* e−6.28 j )+(0* e−9.42 j ) X(2)=(1*1)+(0*-1)+(-1*1)+(0*-1) X(2)= 1+0-1+0 X(2)=0

 Untuk k=3 3

X(3)=

∑ X (n) e n=0

X(3)= X ( 0)e X (3) e

b)

− j 2 π∗3∗n 4

− j 2 π∗3∗0 4

− j 2 π∗3∗3 4

+ X (1) e

− j 2 π∗3∗1 4

+ X (2)e

− j 2 π∗3∗2 4

+

X(3)= (1* e 0 )+(0* e−4.712 j )+(-1* e−9.42 j )+(0* e−14.13 j ) X(3)=(1*1)+(0*1j)+(-1*-1)+(0*-1j) X(3)= 1+0+1+0 X(3)=2

Untuk k=0 N −1

Xk=

∑ X (n)e

− j 2 πkn N

n=0

X(0)=

3

n=0

X(0)= X (0) e X (3) e

− j 2 π∗0∗n 4

∑ X (n) e

− j 2 π∗0∗0 4

− j 2 π∗0∗3 4

+ X (1) e

− j 2 π∗0∗1 4

+ X (2) e

− j 2 π∗0∗2 4

X(0)= (1* e 0 )+(0* e 0 )+(-1* e 0 )+(-1* e 0 ) X(0)=(1*1)+(0*1)+(-1*1)+(-1*1) X(0)=1+0-1-1 X(0)=-1

 Untuk K=1 3

X(1)=

− j 2 π∗1∗n 4

∑ X (n)e n=0

X(1)= X ( 0)e X (3) e

+

− j 2 π∗1∗0 4

− j 2 π∗1∗3 4

+ X (1) e

− j 2 π∗1∗1 4

+ X (2) e

− j 2 π∗1∗2 4

+

X(1)= (1* e 0 )+(0* e−1.57 j )+(-1* e−3.14 j )+(-1* e−4.71 j ) X(1)=(1*1)+(0*-1j)+(-1*-1)+(-1*1j) X(1)= 1+0+1-1

X(1)=2-1j

 Untuk K=2 3

− j 2 π∗2∗n 4

∑ X (n)e

X(2)=

n=0

X(2)= X (0) e X (3) e

− j 2 π∗2∗0 4

− j 2 π∗2∗3 4

+ X (1) e

− j 2 π∗2∗1 4

+ X (2)e

− j 2 π∗2∗2 4

+

X(2)= (1* e 0 )+(0* e−3.14 j )+(-1* e−6.28 j )+(-1* e−9.42 j ) X(2)=(1*1)+(0*-1)+(-1*1)+(-1*-1) X(2)= 1+0-1-1 X(2)=1

 Untuk k=3 3

− j 2 π∗3∗n 4

∑ X (n) e

X(3)=

n=0

X(3)= X ( 0)e X (3) e

− j 2 π∗3∗0 4

− j 2 π∗3∗3 4

+ X (1) e

− j 2 π∗3∗1 4

+ X (2)e

− j 2 π∗3∗2 4

+

X(3)= (1* e 0 )+(0* e−4.712 j )+(-1* e−9.42 j )+(-1* e−14.13 j ) X(3)=(1*1)+(0*1j)+(-1*-1)+(-1*-1j) X(3)= 1+0+1+1j X(3)=2+1j

c) Untuk k=0 N −1

Xk=

∑ X (n)e

− j 2 πkn N

n=0

X(0)=

3

n=0

X(0)= X (0) e X (3)e

− j 2 π∗0∗n 4

∑ X (n) e

− j 2 π∗0∗0 4

− j 2 π∗0∗3 4

+ X (1) e

− j 2 π∗0∗1 4

+ X (2) e

− j 2 π∗0∗2 4

X(0)= (-1* e 0 )+(1* e 0 )+(1* e 0 )+(1* e 0 ) X(0)=(-1*1)+(0*1)+(-1*1)+(-1*1)

+

X(0)=-1+1+1+1 X(0)=2

 Untuk K=1 3

X(1)=

n=0

X(1)= X ( 0)e X (3) e

− j 2 π∗1∗n 4

∑ X (n)e

− j 2 π∗1∗0 4

− j 2 π∗1∗3 4

+ X (1) e

− j 2 π∗1∗1 4

+ X (2) e

− j 2 π∗1∗2 4

+

X(1)= (-1* e 0 )+(1* e−1.57 j )+(1* e−3.14 j )+(1* e−4.71 j ) X(1)=(-1*1)+(1*-1j)+(1*-1)+(1*1j) X(1)= -1-1j-1+1j X(1)=-2

 Untuk K=2 3

X(2)=

− j 2 π∗2∗n 4

∑ X (n)e n=0

X(2)= X (0) e X (3) e

− j 2 π∗2∗0 4

− j 2 π∗2∗3 4

+ X (1) e

− j 2 π∗2∗1 4

+ X (2)e

− j 2 π∗2∗2 4

+

X(2)= (-1* e 0 )+(1* e−3.14 j )+(1* e−6.28 j )+(-1* e−9.42 j ) X(2)=(-1*1)+(1*-1)+(1*1)+(1*-1) X(2)= -1-1+1-1 X(2)= -2

 Untuk k=3 3

X(3)=

− j 2 π∗3∗n 4

∑ X (n) e n=0

X(3)= X ( 0)e X (3) e

− j 2 π∗3∗0 4

− j 2 π∗3∗3 4

+ X (1) e

− j 2 π∗3∗1 4

+ X (2)e

− j 2 π∗3∗2 4

+

X(3)= (-1* e 0 )+(1* e−4.712 j )+(1* e−9.42 j )+(1* e−14.13 j ) X(3)=(-1*1)+(1*1j)+(1*-1)+(1*-1j) X(3)= -1+1j-1-1j X(3)= -2

d) Untuk k=0 N −1

Xk=



X (n)e

− j 2 πkn N

n=0

3

− j 2 π∗0∗n 4

X(0)= ∑ X (n) e n=0

X(0)= X (0) e X (3) e

− j 2 π∗0∗0 4

− j 2 π∗0∗3 4

+ X (1) e

− j 2 π∗0∗1 4

+ X (2) e

− j 2 π∗0∗2 4

X(0)= (-1* e 0 )+(0* e 0 )+(1* e 0 )+(2* e 0 ) X(0)=(-1*1)+(0*1)+(1*1)+(2*1) X(0)=-1+0+1+2 X(0)=2  Untuk K=1 3

+

− j 2 π∗1∗n 4

∑ X (n)e

X(1)=

n=0

X(1)= X ( 0)e X (3) e

− j 2 π∗1∗0 4

− j 2 π∗1∗3 4

+ X (1) e

− j 2 π∗1∗1 4

+ X (2) e

− j 2 π∗1∗2 4

+

X(1)= (-1* e 0 )+(0* e−1.57 j )+(1* e−3.14 j )+(2* e−4.71 j ) X(1)=(-1*1)+(0*-1j)+(1*-1)+(2*1j) X(1)= -1+0-1+2j X(1)=2+2j

 Untuk K=2 3

− j 2 π∗2∗n 4

∑ X (n)e

X(2)=

n=0

X(2)= X (0) e X (3) e

− j 2 π∗2∗0 4

+ X (1) e

− j 2 π∗2∗3 4

− j 2 π∗2∗1 4

+ X (2)e

− j 2 π∗2∗2 4

+

X(2)= (-1* e 0 )+(0* e−3.14 j )+(1* e−6.28 j )+(2* e−9.42 j ) X(2)=(1*1)+(0*-1)+(1*1)+(2*-1) X(2)= -1+0+1-2 X(2)=-2  Untuk k=3 3

X(3)=

∑ X (n) e n=0

X(3)= X ( 0)e X (3) e

− j 2 π∗3∗n 4

− j 2 π∗3∗0 4

− j 2 π∗3∗3 4

+ X (1) e

− j 2 π∗3∗1 4

+ X (2)e

− j 2 π∗3∗2 4

+

X(3)= (-1* e 0 )+(0* e−4.712 j )+(1* e−9.42 j )+(2* e−14.13 j ) X(3)=(-1*1)+(0*1j)+(1*-1)+(2*-1j) X(3)= -1+0-1-2j X(3)=2-2j

e) Untuk k=0 N −1

Xk=

∑ X (n)e

− j 2 πkn N

n=0

3

− j 2 π∗0∗n 4

∑ X (n)e

X(0)=

n=0

X(0)= X ( 0)e X (3)e

− j 2 π∗0∗0 4

− j 2 π∗0∗3 4

+ X (1)e

− j 2 π∗0∗1 4

+ X (2)e

− j 2 π∗0∗2 4

X(0)= (-1* e 0 )+(-1* e 0 )+(1* e 0 )+(-1* e 0 ) X(0)=(-1*1)+(-1*1)+(1*1)+(-1*1) X(0)=-1-1+1-1 X(0)=-2

 Untuk K=1 3

X(1)=

− j 2 π∗1∗n 4

∑ X (n)e n=0

X(1)= X ( 0)e X (3) e

+

− j 2 π∗1∗0 4

− j 2 π∗1∗3 4

+ X (1)e

− j 2 π∗1∗1 4

+ X (2) e

− j 2 π∗1∗2 4

+

X(1)= (-1* e 0 )+(-1* e−1.57 j )+(1* e−3.14 j )+(-1* e−4.71 j ) X(1)=(-1*1)+(-1*-1j)+(1*-1)+(-1*1j) X(1)= -1+1j-1-1j X(1)=-2

 Untuk K=2 3

− j 2 π∗2∗n 4

X(2)= ∑ X (n)e n=0

X(2)= X (0) e X (3) e

− j 2 π∗2∗0 4

− j 2 π∗2∗3 4

+ X (1) e

− j 2 π∗2∗1 4

+ X (2)e

− j 2 π∗2∗2 4

+

X(2)= (-1* e 0 )+(-1* e−3.14 j )+(1* e−6.28 j )+(-1* e−9.42 j ) X(2)=(-1*1)+(-1*-1)+(1*1)+(-1*-1) X(2)= -1+1+1+1 X(2)=2

 Untuk k=3 3

X(3)=

− j 2 π∗3∗n 4

∑ X (n)e n=0

X(3)= X ( 0)e X (3)e

− j 2 π∗3∗0 4

− j 2 π∗3∗3 4

+ X (1)e

− j 2 π∗3∗1 4

+ X (2)e

− j 2 π∗3∗2 4

+

X(3)= (-1* e 0 )+(-1* e−4.712 j )+(1* e−9.42 j )+(-1* e−14.13 j ) X(3)=(-1*1)+(-1*1j)+(1*-1)+(-1*-1j) X(3)= -1-1j-1+1j X(3)=-2

4. Hitunglah DFT untuk masing-masing sinyal di atas (nomor 2) dengan menggunakan MATLAB M-file dft. Bandingkan hasil-hasil ini dengan hasilhasil yang diperoleh secara analitik pada nomor 2 Jawab :

%------------------------------------------------------------------------------% Nama : DAVID SATRIA % NIM : R1A116005 %------------------------------------------------------------------------------xn_4a=[1 0 -1 0]; xn_4b=[1 0 -1 -1]; xn_4c=[-1 1 1 1]; xn_4d=[-1 0 1 2]; xn_4e=[-1 -1 1 -1]; Xk_4a=dft(xn_4a); Xk_4b=dft(xn_4b); Xk_4c=dft(xn_4c); Xk_4d=dft(xn_4d); Xk_4e=dft(xn_4e);

disp('Xk_4a'); disp('Xk_4b'); disp('Xk_4c'); disp('Xk_4d'); disp('Xk_4e');

disp(Xk_4a); disp(Xk_4b); disp(Xk_4c); disp(Xk_4d); disp(Xk_4e);

Xk_4a

0.000000000000000 + 0.000000000000000i 2.000000000000000 + 0.000000000000000i 0.000000000000000 - 0.000000000000000i 2.000000000000000 + 0.000000000000000i

Xk_4b -1.000000000000000 + 0.000000000000000i 2.000000000000000 - 1.000000000000000i 1.000000000000000 + 0.000000000000000i

2.000000000000000 + 1.000000000000000i

Xk_4c 2.000000000000000 + 0.000000000000000i -2.000000000000000 - 0.000000000000000i -2.000000000000000 - 0.000000000000000i -2.000000000000000 - 0.000000000000000i

Xk_4d 2.000000000000000 + 0.000000000000000i -2.000000000000000 + 2.000000000000000i -2.000000000000000 - 0.000000000000000i -1.999999999999999 - 2.000000000000000i Xk_4e -2.000000000000000 + 0.000000000000000i -2.000000000000000 - 0.000000000000000i 2.000000000000000 + 0.000000000000001i -2.000000000000000 - 0.000000000000000i

5. Dengan menggunakan MATLAB M-file dft, hitunglah DFT untuk 32 titik data dari sinyal-sinyal berikut ini. Nyatakan jawabannya dengan membuat plot |𝑋𝑘 | dan fase < 𝑋𝑘 dari hasil DFT : a. (�) = 1 → 0 ≤ � ≤ 10, (�) = 0 → � 𝑙𝑎𝑖�

b. (�) = 1 → 0 ≤ � ≤ 10, (�) = −1 → 11 ≤ � ≤ 20 , �(�) = 0 → � 𝑙𝑎𝑖� c. (�) = � → 0 ≤ � ≤ 20, (�) = 0 → � 𝑙𝑎𝑖�

d. (�) = � → 0 ≤ � ≤ 10, (�) = 20 − � → 11 ≤ � ≤ 20 , �(�) = 0 → � 𝑙𝑎𝑖� e. (�) = cos (10𝜋�/11) → 0 ≤ � ≤ 10, (�) = 0 → � 𝑙𝑎𝑖� f. (�) = cos (9𝜋�/11) → 0 ≤ � ≤ 10, (�) = 0 → � 𝑙𝑎𝑖� Jawab :

a. �(�) = 1 → 0 ≤ � ≤ 10, �(�) = 0 → � 𝑙𝑎𝑖�

%------------------------------------------------------------------------% Nama : DAVID SATRIA % NIM : R1A116005 %------------------------------------------------------------------------clc; clear; format long; xn_5a=zeros(32,1); for i=0:31 if i>=0 && i<=10 xn_5a(i+1)=1; else xn_5a(i+1)=0; end end

Xk_5a=dft(xn_5a); disp('Xk_5a'); disp(Xk_5a); abs_Xk5a=abs(Xk_5a); fase=angle(Xk_5a); figure(1); stem(0:31,abs_Xk5a); xlabel('Frekuensi'); ylabel ('|Xk|'); title('Frekuensi vs |Xk|'); grid on; figure(2); stem(0:31,fase); xlabel('Frekuensi'); ylabel ('Fase'); title('Frekuensi vs Fase'); grid on;

Published with MATLAB® R2014a

b.

%------------------------------------------------------------------------% Nama : DAVID SATRIA % NIM : R1A116005 %------------------------------------------------------------------------clc; clear; format long; xn_5b=zeros(1,32); for i=0:31 if i>=0 && i<=10 xn_5b(i+1)=1; elseif i>=11 && i<=20 xn_5b(i+1)=-1; else xn_5b(i+1)=0; end end

Xk_5b=dft(xn_5b); disp('Xk_5b'); disp(Xk_5b); abs_Xk5b=abs(Xk_5b); fase=angle(Xk_5b); figure(1); stem(0:31,abs_Xk5b); xlabel('Frekuensi'); ylabel ('|Xk|'); title('Frekuensi vs |Xk|'); grid on; figure(2); stem(0:31,fase); xlabel('Frekuensi'); ylabel ('Fase'); title('Frekuensi vs Fase'); grid on;

Published with MATLAB® R2014a

c. Bagian c

%------------------------------------------------------------------------% Nama : DAVID SATRIA % NIM : R1A116005 %------------------------------------------------------------------------clc; clear; format long; xn_5c=zeros(1,32); for i=0:31 if i>=0 && i<=20 xn_5c(i+1)=i; else xn_5c(i+1)=0; end end Xk_5c=dft(xn_5c); disp('Xk_5c'); disp(Xk_5c); abs_Xk5c=abs(Xk_5c); fase=angle(Xk_5c); figure(1); stem(0:31,abs_Xk5c); xlabel('Frekuensi'); ylabel ('|Xk|'); title('Frekuensi vs |Xk|'); grid on; figure(2); stem(0:31,fase); xlabel('Frekuensi'); ylabel ('Fase'); title('Frekuensi vs Fase'); grid on;

Published with MATLAB® R2014a

d. Bagian D

%------------------------------------------------------------------------% Nama : DAVID SATRIA % NIM : R1A116005 %------------------------------------------------------------------------clc; clear; format long; xn_5d=zeros(1,32); for i=0:31 if i>=0 && i<=10 xn_5d(i+1)=i; elseif i>=11 && i<=20 xn_5d(i+1)=20-i; else xn_5d(i+1)=0; end end Xk_5d=dft(xn_5d); disp('Xk_5d'); disp(Xk_5d); abs_Xk5d=abs(Xk_5d); fase=angle(Xk_5d); figure(1); stem(0:31,abs_Xk5d); xlabel('Frekuensi'); ylabel ('|Xk|'); title('Frekuensi vs |Xk|'); grid on; figure(2); stem(0:31,fase); xlabel('Frekuensi'); ylabel ('Fase'); title('Frekuensi vs Fase'); grid on;

Published with MATLAB® R2014a

e. Bagian E

%------------------------------------------------------------------------% Nama : DAVID SATRIA % NIM : R1A116005 %------------------------------------------------------------------------clc; clear; format long; xn_5e=zeros(1,32); for i=0:31 if i>=0 && i<=10 xn_5e(i+1)=cos((10.*pi.*i)/11); else xn_5e(i+1)=0; end end Xk_5e=dft(xn_5e); disp('Xk_5e'); disp(Xk_5e); abs_Xk5e=abs(Xk_5e); fase=angle(Xk_5e); figure(1); stem(0:31,abs_Xk5e); xlabel('Frekuensi'); ylabel ('|Xk|'); title('Frekuensi vs |Xk|'); grid on; figure(2); stem(0:31,fase); xlabel('Frekuensi'); ylabel ('Fase'); title('Frekuensi vs Fase'); grid on;

Published with MATLAB® R2014a

f. Bagian f

%------------------------------------------------------------------------% Nama : DAVID SATRIA % NIM : R1A116005

%------------------------------------------------------------------------clc; clear; format long; xn_5f=zeros(1,32); for i=0:31 if i>=0 && i<=10 xn_5f(i+1)=cos((9.*pi.*i)/11); else xn_5f(i+1)=0; end end Xk_5f=dft(xn_5f); disp('Xk_5f'); disp(Xk_5f); abs_Xk5f=abs(Xk_5f); fase=angle(Xk_5f); figure(1); stem(0:31,abs_Xk5f); xlabel('Frekuensi'); ylabel ('|Xk|'); title('Frekuensi vs |Xk|'); grid on; figure(2); stem(0:31,fase); xlabel('Frekuensi'); ylabel ('Fase'); title('Frekuensi vs Fase'); grid on;

Published with MATLAB® R2014a

More Documents from "David Satria"