Anda di halaman 1dari 24

TUGAS I

PEMROSESAN SINYAL MULTIDIMENSI

Disusun Oleh:

GEDE PRANANDA PUTRA


NRP. 6022231034

MAGISTER TEKNIK ELEKTRO


DEPARTEMEN TEKNIK ELEKTRO
INSTITUT TEKNOLOGI SEPULUH NOPEMBER
SEMESTER GASAL 2023/2024
TUGAS I
Pengolahan Sinyal Multidimensi

1. glassDance.mat
a. Plot sinyal

Terdapat 2 channel sinyal (biru dan merah) dari gambar


Diketahui dari matlab bahwa glassDance memiliki properti panjang data
sebesar 661500 dan srate sebesar 44100
Maka lama panjang sinyal yaitu 661500/44100 = 15 detik
b. Berikut ini plot spektrum daya sinyal dari salah satu channel sinyal
c. Hasil BPF FIR untuk [300 – 460], [1000 – 1100], dan [1200 – 1450] dengan
ordo 100, 1000, dan 2000
Frekuensi 300 – 460 Hz
Frekuensi 1000 – 1100
Frekuensi 1200 – 1450 Hz
d. Plot sinyal terhadap waktu pada jawaban c, dengan membandingkan sinyal
awal dan sinyal setelah proses filter
Frekuensi 300 – 460 Hz
Frekuensi 1000 – 1100
Frekuensi 1200 – 1450 Hz
2. Berikut ini merupakan script matlab pada sinyal sinus dan spikenya:
clear, clc

data = csvread("FunctionGenerator.csv", 4);


time = data(:,1)';
sine = data(:,2)';

% Generate Spike Wave

freqsignal = 50;
timesampling = time(2)-time(1);
freqsampling = 1/timesampling;
sampleprecycle = freqsampling/freqsignal;
sampleprecycle = int32(sampleprecycle);

nrp = 34;
spike = [];k=0;
for i = 1:length(time)
if i == k*sampleprecycle+nrp
spike = [spike 2];
elseif i == (k+1)*sampleprecycle-nrp
spike = [spike -2];
else
spike = [spike 0];
end

if mod(i,sampleprecycle)==0
k=k+1;
end
end
sine_spike = sine+spike;

% Spike Removed and Smoothing Signal


sine_spike_filtered = medfilt1(sine_spike,3);
smoothed_signal = smoothdata(sine_spike_filtered);

figure(1);
subplot(311)
plot(time, sine)
title("Sine Signal")
xlabel('Time (s)'), ylabel('Amplitude')
xlim([0 0.1])
subplot(312)
plot(time, spike)
title("Spike Signal")
xlabel('Time (s)'), ylabel('Amplitude')
xlim([0 0.1])
subplot(313)
plot(time, sine_spike)
title("Sin + Spike Signal")
xlabel('Time (s)'), ylabel('Amplitude')
xlim([0 0.1])

figure(2);
subplot(211)
plot(time, sine_spike_filtered)
title("Median Filtered Signal")
xlabel('Time (s)'), ylabel('Amplitude')
xlim([0 0.1])
subplot(212)
plot(time, smoothed_signal)
title("Smoothed Signal")
xlabel('Time (s)'), ylabel('Amplitude')
figure(2);

subplot(211)
plot(time, sine_spike_filtered)
title("Median Filtered Signal")
xlabel('Time (s)'), ylabel('Amplitude')
xlim([0 0.1])
subplot(212)
plot(time, smoothed_signal)
title("Smoothed Signal")
xlabel('Time (s)'), ylabel('Amplitude')
xlim([0 0.1])

Hasil dari script di atas sebagai berikut:


3. Gaussian Smotthing Signal
a. Hasil Beberapa Perubahan FWHM [10, 50, 100]
FWHM 10
FWHM 50
FWHM 100

Kesimpulan dari 3 gambar diatas, perubahan FWHM yang semakin tinggi


akan menyebabkan perubahan signal input akan semakin smooth.

𝑖+𝑘
b. 𝑓𝑖𝑙𝑡𝑠𝑖𝑔𝐺(𝑡) = ∑𝑗=𝑖−𝑘 signal(j). gauswin(j − 1 + k)

c. Yang membedakan gaussian smoothing dan running mean yaitu, gaussian


smoothing bekerja dengan gaussian coefficient yang menghasilkan sinyal
yang mulus, sedangkan running mean bekerja dengan menggunakan rata-
rata nilai sinyal sehingga masih ada ripple pada hasil sinyal.
4. Whale Sound Filter
Script Matlab
clear, clc

[whale,fs] = audioread('mbari-mars.wav');

% soundsc(whale,fs)

pnts = length(whale);
timevec = (0:pnts-1)/fs;

WLF = lowpass(whale, 0.3, fs/2);

% Plot Frequency Domain


hz1 = linspace(0,fs/2,floor(length(whale)/2)+1);
powr1 = abs(fft(whale)/pnts);
hz2 = linspace(0,fs/2,floor(length(WLF)/2)+1);
powr2 = abs(fft(WLF)/pnts);

figure;
subplot(211), cla
plot(timevec, whale)
xlabel('Time (s)'), ylabel('Amplitude')
hold on
plot(timevec, WLF)
xlabel('Time (s)'), ylabel('Amplitude')
subplot(212), cla
plot(hz1,powr1(1:length(hz1)))
set(gca,'xlim',[100 2000],'ylim',[0 max(powr1)])
xlabel('Frequency (Hz)'), ylabel('Amplitude')
hold on
plot(hz2,powr2(1:length(hz2)))
set(gca,'xlim',[100 2000],'ylim',[0 max(powr2)])
xlabel('Frequency (Hz)'), ylabel('Amplitude')

soundsc(WLF,fs)

Dari script di atas didapatkan gambar sebagai berikut:


Sinyal berwarna biru menunjukan sinyal awal dari “mbari-mars.wav” dan
sinyal berwarna merah merupakan hasil dari filter lowpass pada “mbari-mars.wav”
dengan frekuensi cutoff pada (0.3) Hz

Frekuensi Cutoff 0,1 Hz


Frekuensi Cutoff 100 Hz

Frekuensi Cutoff 150 Hz


Frekuensi Cutoff 200 Hz

Kesimpulan
Saat frekuensi cutoff diubah-ubah, maka akan didapatkan hasil seperti
gambar diatas. Untuk nilai minimum cutoff dapat digunakan sebesar 0,1 Hz
dikarenakan hasil yang didapatkan tidak berbeda jauh dengan cutoff 0,3 Hz. Untuk
nilai maksimal cutoff dapat digunakan sebesar 150 Hz. Hal tersebut didapatkan jika
memainkan suara hasil filter dengan sample waktu 2:22 – 2:42 dengan syntax
“soundsc(WLF(2272000:2592000,:), fs)” maka noise masih terdengar pada
frekuensi cutoff 200 Hz.

5. Hasil matlab sebagai berikut


Plot sinyal bernoise dalam time domain
Plot sinyal dalam frequency domain

Zoom sinyal di 50 Hz

Hasil sinyal setelah filter BSF Notch dalam time domain


Hasil sinyal setelah BSF Notch filter dalam frequency domain

Zoom pada 50 Hz
6. Script Matlab:
clear, clc
%Generate Signal
srate = 1000;
time = -1:1/srate:1;
pnts = length(time);
hz = linspace(0,srate/2,floor(pnts/2)+1);
%Sine Wave Signal
sinewave1 = 5*sin(2*pi*3*time+pi/7); % Signal: 5sin(2𝜋3𝑡+𝜋/7)
sinewave2 = 15*sin(2*pi*10*time+pi/8); % Signal: 15sin(2𝜋10𝑡+𝜋/8)
sinewave3 = 10*sin(2*pi*5*time+pi); % Signal: 10sin(2𝜋5𝑡+𝜋)
sinewave4 = 5*sin(2*pi*15*time+pi/2); % Signal: 5sin(2𝜋15𝑡+𝜋/2)
sinewave5 = 7*sin(2*pi*35*time-pi/4); % Signal: 7sin(2𝜋35𝑡-𝜋/4)
% Plot All Input Signal
figure(1);
sgtitle("Input Signal")
subplot (511), cla
plot(time, sinewave1)
xlim([-1 1])
ylim([-10 10])
subplot (512), cla
plot(time, sinewave2)
xlim([-1 1])
ylim([-20 20])
subplot (513), cla
plot(time, sinewave3)
xlim([-1 1])
ylim([-15 15])
subplot (514), cla
plot(time, sinewave4)
xlim([-1 1])
ylim([-10 10])
subplot (515), cla
plot(time, sinewave5)
xlim([-1 1])
ylim([-10 10])
% Sum of Sinewave
sum_sinewave = sinewave1 + sinewave2 + sinewave3 + sinewave4 +
sinewave5;
figure(2);
sgtitle("Sum of Sinewave")
subplot(211)
plot(time, sum_sinewave)
xlabel('Time (s)'), ylabel('Amplitude')
xlim([-1 1])
title("Time Domain")

% Plot Frequency Domain

hz1 = linspace(0,srate/2,floor(length(sum_sinewave)/2)+1);
powr1 = abs(fft(sum_sinewave)/pnts);
subplot (212)
plot(hz1,powr1(1:length(hz1)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
xlim([0 50])
title("Frequency Domain")
% BPF Sum of Sinewave
FilSig1 = bandpass(sum_sinewave, [2.5 3.5], srate);
FilSig2 = bandpass(sum_sinewave, [4.5 5.5], srate);
FilSig3 = bandpass(sum_sinewave, [9.5 10.5], srate);
FilSig4 = bandpass(sum_sinewave, [14.5 15.5], srate);
FilSig5 = bandpass(sum_sinewave, [34.5 35.5], srate);
% Plot Frequency Domain Filtered Signal
hzfilt1 = linspace(0,srate/2,floor(length(FilSig1)/2)+1);
powrfilt1 = abs(fft(FilSig1)/pnts);
hzfilt2 = linspace(0,srate/2,floor(length(FilSig2)/2)+1);
powrfilt2 = abs(fft(FilSig2)/pnts);
hzfilt3 = linspace(0,srate/2,floor(length(FilSig3)/2)+1);
powrfilt3 = abs(fft(FilSig3)/pnts);
hzfilt4 = linspace(0,srate/2,floor(length(FilSig4)/2)+1);
powrfilt4 = abs(fft(FilSig4)/pnts);
hzfilt5 = linspace(0,srate/2,floor(length(FilSig5)/2)+1);
powrfilt5 = abs(fft(FilSig5)/pnts);
figure(3);
sgtitle("Filtered Sum of Sinewave Properties")
subplot(511)
plot(hz1,powr1(1:length(hz1)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
hold on
plot(hzfilt1,powrfilt1(1:length(hzfilt1)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
xlim([0 50])
subplot(512)
plot(hz1,powr1(1:length(hz1)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
hold on
plot(hzfilt2,powrfilt2(1:length(hzfilt2)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
xlim([0 50])
subplot(513)
plot(hz1,powr1(1:length(hz1)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
hold on
plot(hzfilt3,powrfilt3(1:length(hzfilt3)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
xlim([0 50])
subplot(514)
plot(hz1,powr1(1:length(hz1)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
hold on
plot(hzfilt4,powrfilt4(1:length(hzfilt4)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
xlim([0 50])
subplot(515)
plot(hz1,powr1(1:length(hz1)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
hold on
plot(hzfilt5,powrfilt5(1:length(hzfilt5)))
xlabel('Frequency (Hz)'), ylabel('Amplitude')
xlim([0 50])
Dari script di atas didapatkan hasil sebagai berikut:
Bentuk masing-masing sinyal sin:

Sum of Sinewave (Time Domain):


Sum of Sinewave (Frequency Domain)

Dari gambar di atas, didapatkan bahwa sinyal “Sum of Sinewave” memiliki


property frekuensi masing-masing yaitu 3 Hz, 5 Hz, 10 Hz, 15 Hz, dan 35 Hz yang
nantinya akan difilter menggunakan bandpass filter. Hasil filter masing-masing
property sinyal yaitu sebagai berikut:
Bandpass 2.5 – 3.5 Hz

Bandpass 4.5 – 5.5 Hz

Bandpass 9.5 – 10.5 Hz


Bandpass 14.5 – 15.5 Hz

Bandpass 34.5 – 35.5 Hz

Anda mungkin juga menyukai