net/publication/311717122
CITATION READS
1 74,026
2 authors:
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Mochammad Ariyanto on 19 December 2016.
1. Pendahuluan
- Apa itu MATLAB
- Keunggulan-keunggulan MATLAB
2. Lingkungan Kerja MATLAB
- Memulai MATLAB
- Command Window
- Workplace
- Current Directory
- Command History
3. Variabel dan Operator
- Definisi dari Variabel dan operator
- Contoh-contoh operator
4. Matriks dan vektor
- Cara penulisan vector dan matriks di MATLAB
5. Pemrograman pada MATLAB
M-File
Logical Operation (Programming)
- For
- While
- Switch
- If
6. Plotting Graphical dan suara
- 2D
- 3D
- Movie
- Suara/musik
7. Statistik menggunakan MATLAB
8. Penyelesaian system persamaan aljabar
9. Analisis fungsi dan interpolasi
10. Aplikasi-aplikasi dalam ilmu matematika
- Fourier
- Integral
- Differential
- Polynomial
11. Referensi
Bab I
Pendahuluan
1
Tersedia banyak toolbox untuk aplikasi-aplikasi khusus seperti;
Simulink, Neural Network, State Flow, Data Acquisition Toolbox,
Communications Blockset, Fuzzy Logic Toolbox, Image
Acquisition Toolbox, Signal Processing Blockset, dan lain
sebagainya.
Dalam menulis kode programnya, tidak harus mendeklarasikan
array terlebih dahulu.
Memiliki waktu pengembangan program yang lebih cepat
dibandingkan dengan pemrograman tradisional seperti Fortran,
dan C.
2
Bab II
Lingkungan Kerja MATLAB
3
Bab VI
Grafik dan Suara
>> x=1:1:9;
>> y=[10 11 15 14 13 17 15 18 16];
>> plot(x,y)
4
BELUM
DIKASIH
KETERANG
AN
>> clear
>> x=-6:1:6;
>> y=2*x.^2+5*x-7;
>> plot(x,y)
>> xlabel('sumbu x')
>> ylabel('sumbu y')
>> title(' Plot kurva y=2x^2+5x-7')
>> grid
6
Plot kurva y=2x 2+5x-7
100
80
60
sumbu y
40
20
-20
-6 -4 -2 0 2 4 6
sumbu x
7
c Cyan + Tanda plus -- Garis terpotong-
potong
m Magenta * Bintang
Y Kuning s Bujursangkar
K Hitam d Diamond
w Putih ^ Segitiga ke
atas
v Segitiga ke
bawah
< Segitiga ke
kiri
> Segitiga ke
kanan
p Pentagram
h Heksagram
40
fungsi x, y, dan z
30
20
10
-10
-20
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t
Fungsi keterangan
semilogy( ... ) Plot dengan sumbu-y menggunakan
skala logaritmik (basis 10)
semilogx( ... ) Plot dengan sumbu-x menggunakan
skala logaritmik (basis 10)
loglog( ... ) Plot dengan sumbu-x dan sumbu-y
menggunakan skala logaritmik (basis 10)
9
Kita akan mocoba command pada tabel 6.3, yaitu pada fungsi
semilogy dengan fungsi eksponensial positif. Ketikkan beberapa
kode pada M-file seperti di bawah ini.
clear all
clc
x=linspace(0,5,500);
y1=exp(x);
y2=exp(2*x);
y3=exp(3*x);
y4=exp(5*x);
semilogy(x,y1,x,y2,x,y3,x,y4)
grid on
xlabel('sumbu-x')
ylabel('sumbu-y')
title('Kurva y = exp(Ax)')
legend('A=1','A=2','A=3','A=5')
12
Kurva y = exp(Ax)
10
A=1
A=2
10
10 A=3
A=5
8
10
sumbu-y
6
10
4
10
2
10
0
10
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
sumbu-x
y1=exp(-2*x).*sin(20*x) y2=sin(5*x). 2
1 1
0.5 0.5
y1
y2
0 0
-0.5 -0.5
-1 -1
0 1 2 3 4 5 0 1 2 3 4 5
x x
y3=cos(x).*sin(x) y4=cosh(x)
1 80
0.5 60
y3
y4
0 40
-0.5 20
-1 0
0 1 2 3 4 5 0 1 2 3 4 5
x x
12
6.1.2 ezplot
x3 y 2 0
>>syms x y;
>>ezplot(x^3-y^2)
>>grid on
x 3-y 2 = 0
6
0
y
-2
-4
-6
-6 -4 -2 0 2 4 6
x
13
Selain fungsi plot dari ezplot terdapat juga seperti fungsi
berikut ini: ezcontour, ezcontourf, ezmesh, ezmeshc, ezplot3,
ezpolar, dan ezsurf, dan ezsurfc. Untuk mengetahui fungsi tersebut
dapat dicari pada help, demos di MATLAB help.
14
bar barh
1 3
0.9
2
0.8
0.7
1
0.6
0.5 0
0.4
-1
0.3
0.2
-2
0.1
0 -3
-4 -2 0 2 4 0 0.5 1
6.1.4 stairs
15
y=sin(t) y=cos(t)
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
y
y
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
0 5 10 0 5 10
t t
6.1.5 errorbar
Errorbar ………………………………………………………
16
1.4
1.2
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.5 0 0.5 1 1.5 2 2.5 3 3.5
6.1.6 Polar
Polar merupakan suatu perintah dalam MATLAB yang
berfungsi untuk menggambar grafik dalam koordinat polar. Syntax
yang sering digunakan yaitu polar(theta,rho), membuat grafik dalam
koordinat polar, dengan sudut theta dan jari-jari rho.
17
abs(sin(2*t).*cos(2*t) sin(2*t)
90 0.5 90 1
120 60 120 60
180 0 180 0
6.1.7 Stem
Fungsi stem digunakan untuk membuat rangkaian data
diskrit.
18
Plot menggunakan stem
0.35
0.3
0.25
0.2
0.15
0.1
0.05
-0.05
-0.1
-0.15
0 0.5 1 1.5 2 2.5 3 3.5 4
6.1.8 Scatter
……………………..
0.8
50
0.6
0.4 40
0.2
30
0
20
-0.2
-0.4 10
-0.6
0
-0.8
-1 -10
0 5 10 0 5 10
6.1.8 fill
Fill merupakan suatu fungsi pada MATLAB yang digunakan
untuk membuat grafik segi banyak berwarna pada grafik 2 dimensi.
0.5 0.5
0 0
-0.5 -0.5
-1 -1
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
21
Helix
20
15
10
t
0
1
0.5 1
0 0.5
0
-0.5
-0.5
cos(t) -1 -1
sin(t)
22
Persegi panjang
80
60
sumbu Z
40
20
0
20
15 25
20
10 15
5 10
5
sumbu Y 0 0
sumbu X
1 3 5
1 3 5
1 3 5
yi =
10 10 10
15 15 15
20 20 20
23
Perhatikan bahwa matriks xi berisi replikasi baris dari array x
sedangkan yi berisi replika kolom y. Nilai z dihitung dari array xi dan
yi.
24
Gambar 6.16 Contoh plot mesh
25
Meshc digunakan untuk memplot grafik 3-D (mesh surface)
bersama plot kontur di bawah permukan plot.
0.5
-0.5
10
5 10
0 5
0
-5 -5
-10 -10
27
Dalam hal ini digunakan variabel eps, untuk mencegah
perhitungan 0/0 ketika R = 0.
28
Fungsi surf sama dengan surf yang digunakan untuk
membuat plot grafik 3-D dalam bentuk surface tapi untuk
permukaan yang ber ’shading’.
z ye x
2
29
6.2.4 Contour
30
Gambar 6.22 Contoh plot contour
31
Table 6.4 Fungsi sphere
Fungsi Keterangan
sphere generates a sphere consisting of 20-by-20 faces.
sphere(n) draws a surf plot of an n-by-n sphere in the
current figure.
[X,Y,Z] =sphere(n) returns the coordinates of a sphere in three
matrices that are (n+1)-by-(n+1) in size. You
draw the sphere with surf(X,Y,Z) or mesh(X,Y,Z)
32
Cylinder generates x-, y-, and z-coordinates of a unit
cylinder. You can draw the cylindrical object using surf or mesh,or
draw it immediately by not providing output arguments.
33
% Contoh plot cylinder
t = 0:pi/10:2*pi;
[X,Y,Z] = cylinder(3+sin(t));
surf(X,Y,Z)
axis square
34
[x,y] = meshgrid([-10:0.5:10]);
for j = 1:15
z = bessel(0, (j-1)*0.2 + sqrt(x.^2
+y.^2));
surf(x,y,z)
axis([-10 10 -10 10 -.5 1])
M(j) = getframe;
end
frame_order = [1:15 14:-1:1];
number_repeats = 7;
movie(M, [number_repeats frame_order]);
35
h = uicontrol('style','slider','position',...
[10 50 20 300],'Min',1,'Max',16,'Value',1)
for k = 1:16
plot(fft(eye(k+16)))
axis equal
set(h,'Value',k)
M(k) = getframe(gcf);
end
clf
axes('Position',[0 0 1 1])
movie(M,30)
36
6.4 Suara
37
View publication stats