Anda di halaman 1dari 5

Nama : Tantri Utami Manalu

NIM : 14S20023
Soal No. 4

4. Misalkan tiga sinusoid dengan amplitudo dan fase berikut:

a. Buat program MATLAB untuk mengambil sampel setiap sinusoid dan menghasilkan
jumlah tiga sinusoid, yaitu, 𝑥(𝑛) = 𝑥1 (𝑛) + 𝑥2 (𝑛) + 𝑥3 (𝑛), , dengan frekuensi sampling
8.000 Hz. Plot 𝑥(𝑛) pada rentang 0,1 detik.
b. Gunakan fungsi MATLAB fft() untuk menghitung koefisien DFT, dan memplot serta
memeriksa spektrum sinyal 𝑥(𝑛).

Jawab:
a.
Kode program
%Nama : Tantri Utami Manalu
%NIM : 14S20023
%Tugas Nomor 4

clear all; close all;


f = 8000;
t = 0 : 1/f : 0.1;
x1 = 5*cos(2*pi*500*t);
x2 = 5*cos(2*pi*1200*t + 0.25*pi);
x3 = 5*cos(2*pi*1800*t + 0.5*pi);
xn = x1 + x2 + x3;
plot(t, xn);
ylabel('Amplitudo'); xlabel('time');
title('Sum x(n)');

Hasil Plot
b.
Kode Program
%Nama : Tantri Utami Manalu
%NIM : 14S20023
%Tugas Nomor 4

Fs = 8000;
T = 1/Fs;
L = 1000;
t = (0:L-1)*T;
x1 = 5*cos(2*pi*500*t);
x2 = 5*cos(2*pi*1200*t + 0.25*pi);
x3 = 5*cos(2*pi*1800*t + 0.5*pi);
X = [x1; x2; x3];
for i = 1:3
subplot(3,1,i)
stem(t(1:100),X(i,1:100))
title(['Row ',num2str(i),' in the Time
Domain'])
end
n = 2^nextpow2(L);
dim = 2;
Y = fft(X,n,dim);
P2 = abs(Y/L);
P1 = P2(:,1:n/2+1);
P1(:,2:end-1) = 2*P1(:,2:end-1);
for i=1:3
subplot(3,1,i)
stem(0:(Fs/n):(Fs/2-Fs/n),P1(i,1:n/2))
title(['Row ',num2str(i),' in the Frequency
Domain'])
end
Hasil Plot

Anda mungkin juga menyukai