Dibuat Oleh:
Pelsi Ockta Fani (2311079025)
Dosen Pengampu:
Silfia Rifka, S.ST,M.T
Poppy Maria,S.T,M.T
1. Praktikum ke :1
2. Judul Praktikum : Menampilkan Sinyal Grafik dan Suara
3. Praktikan :
Nama : Pelsi Ockta Fani
No. BP : 2311079025
4. Tanggal Praktikum : 6 November 2023
5. Tanggal Penyerahan : 11 November 2023
6. Dosen Pengampu :
Dosen 1 : Silfia Rifka, S.ST, MT
Dosen 2 : Poppy Maria, ST, MT
7. Status Pengumpulan Laporan :
8. Nilai :
PRAKTIKUM I
MENAMPILKAN GRAFIK SINYAL DAN SUARA
1.1 Kompetensi
Fungsi grafik mencakup fungsi merencanakan 2-D dan 3-D untuk mem-
visualisasikan data dan mengkomunikasikan hasil. Kustomisasi plot baik
secara interaktif maupun terprogram. MATLAB R2014a memperkenalkan
sistem grafis MATLAB baru. Warna, font, dan gaya default baru
membuat data Anda lebih mudah diinterpretasikan. Font dan garis anti-alias
memberikan teks dan grafik yang lebih halus. Objek grafik lebih mudah
digunakan dan memberikan sintaksis sederhana untuk mengubah properti.
Banyak fitur baru lainnya juga disertakan. Beberapa kode terkait grafis yang
ada mungkin perlu direvisi agar berfungsi di R2014b. Fungsi grafik yang bisa
ditampilkan pada Matlab adalah :
a) Line Plots
Plot garis, plot log, dan plot fungsi
b) Data Distribution Plots
Histogram, diagram lingkaran, kata cloud, dan banyak lagi
c) Discrete Data Plots
Grafik batang, plot sebar, dan banyak lagi
d) Geographic Plots
Visualisasikan data pada peta
e) Polar Plots
Plot dalam koordinat polar
f) Contour Plots
Plot isoline 2-D dan 3-D
g) Vector Fields
Comet, compass, feather, quiver dan stream plots
h) Surfaces, Volumes, and Polygons
Permukaan grid dan data volume, data poligon tanpa pita
i) Animation
Plot animasi
1.3 Percobaan
1. Ketik program berikut pada matlab dan beri kesimpulan pada setiap fungsi
yang digunakan!
%grafik mesh
[x,y]=meshgrid(-3:0.3:3);
z=x.*exp(-x.^2-y.^2);
figure(1),
subplot(221)
mesh(z),title('subplot(221)’;
subplot(222)
mesh(z)
view(-37.5,70), title('subplot(222)');
subplot(223)
mesh(z)
view(-37.5,-10), title('subplot(223)');
subplot(224)
mesh(z)
view(0,0), title('subplot(224)');
%grafik polar
x=0:pi/40:2*p;
figure(2),
polar(x,sin(2*x)),title('grafik polar'),grid
%grafik Kontur
[x,y]=meshgrid(-2:.2:2); z=x.*exp(-x.^2-y.^2); figure(3),
mesh(z),title('grafikkontur')
%grafik batang
n=[-3, -2, -1, 0, 1,2,3];
y=[1,-1,2,0,1,2,3];
stem(n,y);
figure(4),
f=[1 2 3 4 5];
g=[6 7 8 9 10];
bar(g,f), title ('grafik batang');
Modul I - 3
%plot 3d
figure(5), t=0:pi/100:10*p;
plot3(sin(2*t), cos(2*t), t),title ('grafik sin-cos 3d');
%grafik batang 3d
figure(6),
t=[10 30 21 52; 34 67 12 23; 90, 23, 45, 26; 58 94 30 20];
bar3(t),title ('grafik batang 3d');
%grafik diskrit 3d
t=0:pi/50:2*pi; r=exp(-0.05*t); figure(7),
stem3(r.*sin(t),r.*cos(t),t)
% grafik 3d dengan pita ribbon()
[x,y]=meshgrid(-8:1:8); r=sqrt(x.^2+y.^2)+eps; z=sin(r)./r;
figure(8),
ribbon(z)
Sekarang, bagian genap dan ganjil dari sinyal dapat diplot sebagai berikut :
Fs=16000;
t=0:1/Fs:0.25;
c=sin(2*pi*131*t);
d=sin(2*pi*147*t);
e=sin(2*pi*165*t);
f=sin(2*pi*175*t);
g=sin(2*pi*196*t);
a=sin(2*pi*220*t);
b=sin(2*pi*247*t);
c1=sin(2*pi*262*t);
d1=sin(2*pi*294*t);
e1=sin(2*pi*330*t);
f1=sin(2*pi*349*t);
g1=sin(2*pi*392*t);
a1=sin(2*pi*440*t);
b1=sin(2*pi*494*t);
c2=sin(2*pi*523*t);
nol = [zeros(size(t))];
nada1=[e,e,f,g,g,g,e1,e1,e1,nol,nol,e1,d1,d1,d1,c1,c1,c1,g,g,g,nol,nol,n
ol,g,
g,g,a,a,a,g,g,g,f,f,f,e,e,e,d,d,d,d,d,d,nol,nol,nol];
nada2=[d,d,e,f,f,f,d1,d1,d1,nol,nol,d1,c1,c1,c1,b,b,b,a,a,a,nol,nol,nol,
g,g,g
,b,b,b,a,a,a,g,g,g,f,f,f,e,e,e,e,e,e,nol,nol,nol];
nada3=[e,e,f,g,g,g,e1,e1,e1,nol,nol,e1,d1,d1,d1,c1,c1,c1,g,g,g,nol,nol,n
ol,g,
g,g,a,a,a,g,g,g,c1,c1,c1,d1,d1,d1,b,b,b,b,b,b,a,a,nol,];
nada4=[a,a,a,f1,f1,f1,f1,f1,f1,e1,e1,e1,d1,d1,d1,g1,g1,g1,g1,g1,g1,c1,c1
,nol,
b,b,a,g,g,g,f1,f1,f1,e1,e1,e1,d1,d1,d1,c1,c1,c1,c1,c1,c1,nol];
lagu=[nada1,nada2,nada3,nada4];
sound(lagu,Fs);
f2=sin(4*pi*350*t);
f3=sin(8*pi*350*t);
f4=sin(16*pi*350*t);
g0=sin(1*pi*390*t); % nada g
g0c=sin(1*pi*420*t);
g1=sin(2*pi*390*t);
g1c=sin(2*pi*420*t);
g2=sin(3*pi*515*t);
g3=sin(4*pi*390*t);
g4=sin(5*pi*390*t);
a0=sin(1*pi*440*t); % nada a
a1=sin(2*pi*440*t);
a2=sin(3*pi*580*t);
a3=sin(4*pi*440*t);
a4=sin(5*pi*440*t);
b0=sin(1*pi*495*t); % nada b
b1=sin(2*pi*495*t);
b2=sin(3*pi*645*t);
b3=sin(4*pi*495*t);
b4=sin(5*pi*495*t);
d2c=sin(3*pi*410*t);
a2c=sin(4*pi*0*t);
d2=sin(3*pi*390*t);
nol=zeros(size(t)); % spasi kosong
ring=[e2,d2c,e2,d2c,e2,b1,d2,c2,a1,nol,a0,c1,e1,a1,b1,nol,g0c,e1,g1c,b1,
c2,no
l,a0,e1,e2,d2c,e2,d2c,e2,b1,d2,c2,a1,nol,a0,c1,e1,a1,b1,nol,g0c,e1,c2,b1
,a1,n
ol,e1,e2,d2c,e2,d2c,e2,b1,d2,c2,a1,nol,a0,c1,e1,a1,b1,nol,g0c,e1,g1c,b1,
c2,no
l,a0,e1,e2,d2c,e2,d2c,e2,b1,d2,c2,a1,nol,a0,c1,e1,a1,b1,nol,g0c,e1,c2,b1
,a1,n
ol,nol,b1,c2,d2,e2,nol,e1,g1,f2,e2,d2,nol,d1,f1,e2,d2,c2,nol,c1,e1,d2,c2
,b1,n
ol,nol,e1,e1,e2,e1,e2,e2,e3,e2,d2c,e2,d2c,e2,d2c,e2,d2c,e2,b1,d2,c2,a1,n
ol,a0
,c1,e1,a1,b1,nol,g0c,e1,g1c,b1,c2,nol,a0,e1,e2,d2c,e2,d2c,e2,b1,d2,c2,a1
,nol,
a0,c1,e1,a1,b1,nol,g0c,e1,g1c,b1,c2,nol,a0,e1,e2,d2c,e2,d2c,e2,b1,d2,c2,
a1,no
l,a0,c1,e1,a1,b1,nol,g0c,e1,c2,b1,a1,nol,nol,b1,c2,d2,e2,nol,e1,g1,f2,e2
,d2,n
ol,d1,f1,e2,d2,c2,nol,c1,e1,d2,c2,b1,nol,nol,e1,e1,e2,e1,e2,e2,e3,e2,d2c
,e2,d
2c,e2,d2c,e2,d2c,e2,b1,d2,c2,a1,a1,a1,a1];
sound(ring,fs);
a. Hasil Percobaan 1
2 %grafik mesh
[x,y]=meshgrid(-3:0.3:3);
z=x.*exp(-x.^2-y.^2);
figure(1),
subplot(221)
mesh(z),title('subplot(221');
subplot(222)
mesh(z)
view(-37.5,70),
title('subplot(222)');
subplot(223)
mesh(z)
view(-37.5,-10),
title('subplot(223)');
subplot(224)
mesh(z)
view(0,0),
title('subplot(224)');
%grafik polar
x=0:pi/40:2*pi;
figure(2),
polar(x,sin(2*x)),title('grafi
k polar'),grid
%grafik Kontur
[x,y]=meshgrid(-2:.2:2);
z=x.*exp(-x.^2-y.^2);
figure(3),
mesh(z),title('grafikkontur')
%grafik batang
y=[1,-1,2,0,1,2,3];
stem(n,y);
figure(4),
f=[1 2 3 4 5];
g=[6 7 8 9 10];
%plot 3d
figure(5), t=0:pi/100:10*pi;
plot3(sin(2*t), cos(2*t),
t),title ('grafik sin-cos
3d');
%grafik batang 3d
figure(6),
t=0:pi/50:2*pi; r=exp(-
0.05*t); figure(7),
stem3(r.*sin(t),r.*cos(t),t)
[x,y]=meshgrid(-8:1:8);
r=sqrt(x.^2+y.^2)+eps;
z=sin(r)./r;
figure(8),
ribbon(z)
b. Hasil Percobaan 2 dan 3
figure(1),
t = 0:.1:10;
y = sin(t);
plot(t,y);
figure(2)
y = sin(t) + sin(3*t)/3;
plot(t,y);
figure(3),
y = sin(t) + sin(3*t)/3 +
sin(5*t)/5 + sin(7*t)/7 +
sin(9*t)/9;
plot(t,y);
figure(4),
t = 0:.02:3.14;
y = zeros(10,length(t));
x = zeros(size(t));
for k = 1:2:19
x = x + sin(k*t)/k;
y((k+1)/2,:) = x;
end
plot(y(1:2:9,:)')
title('Pembentukan sinyal
Persegi: dengan efek Gibbs')
figure(5),
surf(y);
t = 0:.0001:1; % time
A = 2; % amplitude
f = 2; % frequency
W = 0.5;% width
subplot(2,1,1)
plot(t,y )
ylabel ('Amplitude')
grid
A = 3; % amplitude
f = 2; % frequency
subplot(2,1,2);
plot(t ,y )
ylabel ('Amplitudo')
grid
c. Hasil Percobaan 4
t = 0:0.1:1; % time
A = 3; % amplitude
g = A *exp (A *t);
% growing
d = A *exp (- A*t
); % decaying
subplot (2 ,1 ,1)
plot(t ,g )
title ('Peningkatan
Fungsi
Exponensial')
grid
subplot (2 ,1 ,2)
plot(t ,d )
title ('Penurunan
Fungsi
Exponensial')
grid
d. Hasil percobaan 5
t = -1:0.0001:1;
x = 1/2*( t+1) ;
plot(t,x),
grid
hold on
hold off
t = -1:0.0001:1;
x = 1/2*( t+1) ;
x1 =fliplr (x);
xe = 1/2*( x +
x1); % Even part
xo = 1/2*( x -
x1); % Odd part
subplot (2 ,1 ,1)
plot(t, xe)
xlabel ('Waktu')
ylabel ('bagian
genap dari x(t)')
subplot (2 ,1 ,2)
plot (t, xo)
xlabel ('Time')
ylabel ('Bagian
Ganjil dari x(t)')
Fs=16000;
t=0:1/Fs:0.25;
c=sin(2*pi*131*t);
d=sin(2*pi*147*t);
e=sin(2*pi*165*t);
f=sin(2*pi*175*t);
g=sin(2*pi*196*t);
a=sin(2*pi*220*t);
b=sin(2*pi*247*t);
c1=sin(2*pi*262*t);
d1=sin(2*pi*294*t);
e1=sin(2*pi*330*t);
f1=sin(2*pi*349*t);
g1=sin(2*pi*392*t);
a1=sin(2*pi*440*t);
b1=sin(2*pi*494*t);
c2=sin(2*pi*523*t);
nol = [zeros(size(t))];
nada1=[e,e,f,g,g,g,e1,e1,e1,nol,nol,e1,d1,d1,d1,c1,c1,c1,g,g,g,nol,nol,n
ol,g,
g,g,a,a,a,g,g,g,f,f,f,e,e,e,d,d,d,d,d,d,nol,nol,nol];
nada2=[d,d,e,f,f,f,d1,d1,d1,nol,nol,d1,c1,c1,c1,b,b,b,a,a,a,nol,nol,nol,
g,g,g
,b,b,b,a,a,a,g,g,g,f,f,f,e,e,e,e,e,e,nol,nol,nol];
nada3=[e,e,f,g,g,g,e1,e1,e1,nol,nol,e1,d1,d1,d1,c1,c1,c1,g,g,g,nol,nol,n
ol,g,
g,g,a,a,a,g,g,g,c1,c1,c1,d1,d1,d1,b,b,b,b,b,b,a,a,nol,];
nada4=[a,a,a,f1,f1,f1,f1,f1,f1,e1,e1,e1,d1,d1,d1,g1,g1,g1,g1,g1,g1,c1,c1
,nol,
b,b,a,g,g,g,f1,f1,f1,e1,e1,e1,d1,d1,d1,c1,c1,c1,c1,c1,c1,nol];
lagu=[nada1,nada2,nada3,nada4];
sound(lagu,Fs);
1.5 Analisa
1.6 Kesimpulan
[1] https://repository.uki.ac.id/2747/1/bukumatlabanalisakomputasi.pdf
[2] https://id.wikipedia.org/wiki/Deret_Fourier
[3] https://repository.dinus.ac.id/docs/ajar/Fourier_Series-Presentasi.pdf
[4] Ferdinando, Hany 2010, Dasar-Dasar Sinyal dan Sistem, Surabaya : Penerbit
Andi
[5] http://eprints.undip.ac.id/25444/1/ML2F000574.pdf /Penala Alat Musik
Menggunakan Alihragam Fourier
LAMPIRAN 1 : TUGAS
1 t=0:0.01:1;
f=1;
a=1;
x=a*sin(2*pi*f*t);
plot(t(1:100),x(1:100),'r','LineW
idth',3);
xlabel('waktu(t)');
ylabel('amplitudo');
grid on
t = 0:.0001:1; % time
A = 1; % amplitude
f = 2; % frequency
W = 0.5; % width
ylabel ('Amplitude')
grid on
clc , clear all , close all
t = 0:.0001:1; % time
A = 1; % amplitude
f = 2; % frequency
W = 0.5; % width
ylabel ('Amplitude')
grid on
t = 0:.0001:1; % time
A = 1; % amplitude
f = 1; % frequency
W = 0.5; % width
ylabel ('Amplitude')
grid on
clc, clear all, close all
t = 0:0.01:1; % time
A = 1; % amplitude
f = 2; % frequency
W = 0.5; % width
y1= A*sin(2*pi*f*t);
plot(t,y1,'r*','LineWidth',1.5)
hold on
plot (t ,y3,'y','LineWidth',2.5)
plot (t ,y2,'b--','LineWidth',2)
hold off
legend('Sinus','Segitiga', 'Gigi
Gergaji', 'Persegi')
ylabel ('Amplitude')
grid on
LAMPIRAN 2 : TUGAS
Menampilkan lagu Jepang Blue Bird – Ikomotogahari (Ost. Naruto)
Fs=30000;
t=0:1/Fs:0.25;
C4=sin(2*pi*261.6*t);
E4=sin(2*pi*329.6*t);
F4=sin(2*pi*349.6*t);
G4=sin(2*pi*392.0*t);
A4=sin(2*pi*440.0*t);
B4=sin(2*pi*493.9*t);
C5=sin(2*pi*523.3*t);
F5= sin(2*pi*698.5*t);
nol =[zeros(size(t))];
uchiha1=
[C4,F4,G4,A4,G4,F4,nol,C4,F4,G4,A4,nol,B4,A4,B4,B4,C5,nol];
uchiha2 =
[C4,F4,G4,A4,nol,G4,nol,F4,nol,F4,C5,B4,nol,F4,C5,B4,nol];
uchiha3=[E4,E4,nol,F4,F4];
lagu=[uchiha1,uchiha2,uchiha3];
sound(lagu,Fs)