clear
clc
%skalar
a = 10;
%matriks kolom 3 x 1
c = [ 1; 5; 6];
%matriks 3 x 3
d = [ 10 20 30 ; 40 50 60; 70 80 90]
%menggabungkan matriks
gabung1 = [ c d ];
gabung2 = [ d c ];
gabung3 = [ b; d];
gabung4 = [ d; b];
ones (1);
ones (2);
ones (4);
zeros (1);
zeros (3);
kolom1 = d(:,1);
kolom2 = d(:,2);
kolom3 = d(:,3);
baris23 = d(1:2,2:3)
d(1, 2:3);
baris13 = d (1:3,2:3);
f = [ 1 2 ; 4 5]
fliplr (f)
flipud (f)
rot90 (f)
%operasi matrks
%1. penjumlahan dan pengurangan matriks
h = d + e
i = d - e
j = [ 1 2 3] %vektor
k = [ 4; 5; 6] %vektor
dot (j,k)
cross (j,k)
r = e (:,3)
dot (baris2, r)
%determinan matriks
det (e)
%invers
invers = inv (d)
25feb2019
clear
clc
%plot 2 dimensi
x = -5 : 0.5 :5
a = 10.*10.*45
b = -8*x.^2 - 10
legend ('x - a', 'x - b') %keterangan tambahan pojok kanan atas
25feb2019(2)
clear
clc
%x = 0: 0.1 :10
% a = sin (x)
%b = cos (x)
%grid on
%hold on
%plot (x,a)
%plot (x,b)
%subplot adalah menampilkan dua grafik beda bukan gabungan
%subplot (2,1,1) ; plot (x,a) % 2= jumlah subplot, 1=jumlah didalam nya, 1=
jumlah baris ke brapa
%subplot (2,1,2) ; plot (x,b)
%subplot (2,1,1)
%title ('Grafik sinus')
%xlabel ('nilai x')
%ylabel ('nilai a')
%subplot (2,1,2)
%title ('Grafik sinus')
%xlabel ('nilai x')
%ylabel ('nilai b')
%x = [2.5, 2.5, 5]
%pie (x) %grafik bulat
%grafik 3 dimensi
%x = 1 : 10
%y = 11 : 20
%z = 21 : 30
%plot3 (x,y,z)
%grid on
%title ('grafik faris 3 dimensi')
%xlabel ('nilai x')
%ylabel ('nilai y')
%zlabel ('nilai z')
%t = 0 : 0.1 : 25
%x = sin (t);
%y = cos (t) ;
%z = 0.5 * t
%plot3 (x,y,z)
%grid on
%title ('grafik garis helix')
%xlabel ('nilai x')
%ylabel ('nilai y')
%zlabel ('nilai z')
%plot permukaan
%z = x.^2 + y.^2
%mesh (x,y,z)
%surf (x,y,z)
%grafik kontur
%contour (x,y,z)
%Eksponensial
%[x,y] = meshgrid (-5:0.1:5. -4:0.1:4)
%z = x.*exp (-x.^2-y.^2)
%mesh (x,y,z)
%contour (x,y,z)
4mar2019
clc
clear
a = [ 1 -2; 12 5]
b = [ 32; 7]
x = inv (a) * b
A = [ 1 2 3; 3 3 4; 2 3 3]
B = [1; 1; 2]
X = A\B
(2)
clear
clc
%menghitung X
x = v0*t + 1/2*a*t.^2;
a = [ 1 -2; 12 5]
b = [ 32; 7]
x = inv (a) * b
A = [ 1 2 3; 3 3 4; 2 3 3]
B = [1; 1; 2]
X = A\B
control statment
%control stetment
%meruakan suatu kode yang digunakan untuk mengatur alur program. ada 4
%program kontrol
%1. loop kontrol
%2. conditional control
%3. error control
%4. program termination
%LOOP CONTROL BISA DIGUNAKAN PERNYATAAN for DAN while. utk mengulang suatu
%proses
%for= jika diketahui jumlah perulangannya (sudah ditentuka)
%while = akan menjalankan pernyataan selama masih memenuhi syarat
%bentuk umum: for indeks = mulai:penambahan:akhir pernyataan/perintah
%end
clear
clc
for x = 1:10
y(x) = x.^2 + 3*x + 5
end