Matlab Kel8
Matlab Kel8
Contoh 2.1:
Contoh 2.2:
x=[-5 -4 -3 -2 -1 0 1 2 3 4 5 6]
x= -5 -4 -3 -2 -1 0 1 2 3 4 5 6
y=2*x+3
y= -7 -5 -1 1 3 5 7 9 11 13 15
Pengalamatan Array
Contoh 2.3:
x=[-5 -4 -3 -2 -1 0 1 2 3 4 5 6]
x= -5 -4 -3 -2 -1 0 1 2 3 4 5 6
y=2*x+3
y=-7 -5 -3 -1 1 3 5 7 9 11 13 15
Ans= -1
Ans=11
Contoh 2.4:
Ans= -4 -3 -2 -1 0 1
Contoh 2.5:
Ans= -1 1 3 5
Ans= 15 13 11 9 7 5 3 1
Mengkonstruksi array
Contoh 2.6:
X= -5 -4 -3 -2 -1 0 1 2 3 4 5 6
Contoh 2.7:
Array linspace
Contoh 2.8:
Pecah=linspace(0.5,-2.5,5)
X=linspace(-5,6,12)
X= -5 -4 -3 -2 -1 0 1 2 3 4 5 6
Contoh 2.9:
P=(-3:1.5:4.5)
r= columns 1 through 7
Columns 8 through 11
Contoh 2.10:
a= (5:-2:-1)
a= -5 3 1 -1
b= linspace(2,4,5)
c=[a b(1:2:5)]
c= 5 3 1 -1 2 3 4
contoh 2.11:
k=5;
a=[-1 2 1 3];
k+a
ans= 4 7 6 8
a+k
ans=4 7 6 8
a-k
ans=-6 -3 -4 -2
k-a
ans=6 3 4 2
k*a
ans= -5 10 5 15
a*k
ans= -5 10 5 15
a/k
k./a
a.^k
ans=-1 32 1 243
k.^a
contoh 2.12:
p=[2 -1 3 1];
q=[1 5 0 -2];
p+q
ans= 3 4 3 -1
q-p
ans= -1 6 -3 -3
p.*q
ans= 2 -5 0 -2
q.*p
ans= 2 -5 0 -2
p./q
q./p
p.^q
ans= 2 -1 1 1
q.^p
Orientasi Array
Contoh 2.13:
x= [-2;3;4;5;1]
x=
-2
Contoh 2.14:
a= -2 1 4 7
-2
Contoh 2.15:
z=
2.0000 – 5.0000i
7.0000
-3.0000 + 8.0000i
y=
2.0000 + 5.0000i
7.0000
-3.0000 – 2.0000i
0+9.0000i
4.0000-8.0000i
Contoh 2.16:
B=
-1 0 3 5
2 4 1 -3
7 9 -8 6
Contoh 2.17:
B= [-1,0,3,5;2,4,1,-3;7,9,-8,6]
B=
-1 0 3 5
2 4 1 -3
7 9 -8 6