OLEH
DWI YOGA PRATAMA (1404405014)
UNIVERSITAS UDAYANA
FAKULTAS TEKNIK
JURUSAN TEKNIK ELEKTRO DAN KOMPUTER
2016
1. Practice 2.3
a).
>> 2^5/(2^6 - 1)
ans =
0.5079
b).
>> exp(4)
ans =
54.5982
Gambar 1.b Hasil Matlab
c).
>> log(exp(4))
ans =
d).
>> log10(exp(4))
ans =
1.7372
e).
>> exp(sqrt(121))
ans =
5.9874e+04
ans =
1.4571
g).
>> log(exp(3))+log10(exp(1))
ans =
3.4343
h).
>> area=pi*((pi/3)^2)
area =
3.4451
Gambar 2 Soal
Jawaban:
a).
>> solve 2^x=7
ans =
log(7)/log(2)
>> ans
ans =
log(7)/log(2)
>> log(7)/log(2)
ans =
2.8074
ans =
exp(3)
>> exp(3)
ans =
20.0855
ans =
log(10)
>> log(10)
ans =
2.3026
Gambar 2.c Hasil Matlab
d).
>> solve sqrt((3^(1/3))*(9^(1/3)))=(1/3)^x
ans =
-1/2
e).
>> solve sqrt(2)/6^3=3^x
ans =
-log(108*2^(1/2))/log(3)
>> -log(108*2^(1/2))/log(3)
ans =
-4.5773
Gambar 3 Soal
Jawaban:
jarak_dari_t1t2 =
10
jarak_dari_t1t3 =
jarak_dari_t2t3 =
spm =
>> lss=sqrt(spm*(spm-jarak_dari_t1t2)*(spm-jarak_dari_t1t3)*(spm-
jarak_dari_t2t3))
lss =
0.0000 +14.6969i
Gambar 3 Hasil Matlab
4. Practice 2.26
Gambar 4 Soal
Jawaban:
a).
>> t00=5; t01=-1;
>> t10=3; t11=2;
>> distance = sqrt((t00-t10)^2+(t01-t11)^2)
distance =
3.6056
>> slope=(t11-t01)/(t10-t00)
slope =
-1.5000
b).
>> t00=8; t01=1;
>> u10=9; u11=0;
>> distance = sqrt((u00-u10)^2+(u01-u11)^2)
distance =
1.4142
>> slope=(u11-u01)/(u10-u00)
slope =
-1
c).
>> a00=5; a01=3;
>> a10=-1; a11=7;
>> distance = sqrt((a00-a10)^2+(a01-a11)^2)
distance =
7.211102550927978
>> slope=(a11-a01)/(a10-a00)
slope =
-0.666666666666667
Gambar 4.c Hasil Matlab
5. Practice 2.37
Gambar 5 Soal
ans =
Gambar 6 Soal
>> x=[1:10];
a).
>> ans_a=x-x
ans_a=
0 0 0 0 0 0 0 0 0 0
b).
>> ans_b=x.^x
ans_b =
1.0e+10 *
c).
>> ans_c=x.*x
ans_c =
1 4 9 16 25 36 49 64 81 100
d).
>> ans_d=x*x'
ans_d =
385
ans_e =
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
f).
>> ans_f=x.\x
ans_f =
1 1 1 1 1 1 1 1 1 1
ans_g =
1 1 1 1 1 1 1 1 1 1
h).
>> x = 'x', ans_h = x
x =
ans_h =
Gambar 7 Soal
Jawaban:
>> MARK = [0 1 ; 1 0]
MARK =
0 1
1 0
>> MARK'*MARK
ans =
1 0
0 1
>> MARK*MARK'
ans =
1 0
0 1
>> inv(MARK)
ans =
0 1
1 0
>> orth(MARK)
ans =
0 -1
-1 0
Gambar 7.a Hasil Coding pada Matlab
8. R.3.64
Gambar 8 Soal
Jawaban:
>> X=[cosd(0) -sind(0); sind(0) cosd(0)]
X =
1 0
0 1
>> X'
ans =
1 0
0 1
>> inv(X)
ans =
1 0
0 1
X =
-1 0
0 -1
>> X'
ans =
-1 0
0 -1
>> inv(X)
ans =
-1 0
0 -1
Matriks ini orthogonal karena X=inv(X)
Gambar 8b. Hasil coding pada Matlab
X =
1 0
0 1
>> X'
ans =
1 0
0 1
>> inv(X)
ans =
1 0
0 1
X =
-1 0
0 -1
>> X'
ans =
-1 0
0 -1
>> inv(X)
ans =
-1 0
0 -1
X =
1 0
0 1
>> X'
ans =
1 0
0 1
>> inv(X)
ans =
1 0
0 1
Gambar 9 Soal
Untuk point = 3
>> x1=linspace(-5,2,3)
x1 =
>> y1=x1.^3+4*x1.^2-x1-4
y1 =
Untuk point = 4
>> x2=linspace(-5,2,4)
x2 =
>> y2=x2.^3+4*x2.^2-x2-4
y2 =
Untuk point = 5
>> x3=linspace(-5,2,5)
x3 =
>> y3=x3.^3+4*x3.^2-x3-4
y3 =
Untuk point = 6
>> x4=linspace(-5,2,6)
x4 =
>> y4=x4.^3+4*x4.^2-x4-4
y4 =
-24.0000 4.7840 6.9120 -1.1520 -2.9440 18.0000
Untuk point = 7
>> x5=linspace(-5,2,7)
x5 =
>> y5=x5.^3+4*x5.^2-x5-4
y5 =
x6 =
Columns 1 through 12
Columns 13 through 24
-4.1600 -4.0900 -4.0200 -3.9500 -3.8800 -3.8100 -3.7400
-3.6700 -3.6000 -3.5300 -3.4600 -3.3900
Columns 25 through 36
Columns 37 through 48
Columns 49 through 60
Columns 61 through 72
Columns 73 through 84
Columns 85 through 96
>> y6=x6.^3+4*x6.^2-x6-4
y6 =
Columns 1 through 12
Columns 13 through 24
Columns 25 through 36
Columns 49 through 60
Columns 61 through 72
Columns 73 through 84
Columns 85 through 96
Gambar 10 Soal
Jawaban:
>> x1 = linspace (0,2,5)
x1 =
>> a = x1*pi
a =
x2 =
>> b = x2*pi
b =
>> x3 = linspace(0,2,15)
x3 =
Columns 1 through 12
Columns 13 through 15
>> c = x3*pi
c =
Columns 1 through 12
>> x4 = linspace(0,2,20)
x4 =
Columns 1 through 12
Columns 13 through 20
>> d = x4*pi
d =
Columns 1 through 12
Columns 13 through 20
>> y1 = 1.5*cos(2*a)
y1 =
>> y2 = 1.5*cos(2*b)
y2 =
>> y3 = 1.5*cos(2*c)
y3 =
Columns 1 through 12
Columns 13 through 15
y4 =
Columns 1 through 12
Columns 13 through 20
Gambar 11 Soal
Jawaban:
>> x = [-2:0.4:2]*pi
x =
>> y1 = sin(x)
y1 =
>> y2 = sind(x)/x
y2 =
0.0174
>> plot(x,y1,'r-*',x,y2,'b-^')
>> ylabel('variabel y bebas')
>>
>> xlabel ('variabel x bebas')
>> grid on
Gambar 11.a Hasil pada Matlab
Gambar 12 Soal
Jawaban:
>> noice= rand(1,100)
noice =
Columns 1 through 12
Columns 13 through 24
Columns 25 through 36
Columns 37 through 48
Columns 49 through 60
Columns 61 through 72
Columns 73 through 84
Columns 85 through 96
>> x=linspace(0,3,100)
x =
Columns 1 through 12
Columns 13 through 24
Columns 25 through 36
Columns 37 through 48
Columns 49 through 60
Columns 61 through 72
Columns 73 through 84
Columns 85 through 96
>> x1=x*pi
x1 =
Columns 1 through 12
0 0.0952 0.1904 0.2856 0.3808 0.4760 0.5712
0.6664 0.7616 0.8568 0.9520 1.0472
Columns 13 through 24
Columns 25 through 36
Columns 37 through 48
Columns 49 through 60
Columns 61 through 72
Columns 73 through 84
Columns 85 through 96
>> y1=10*sin(x1)
y1 =
Columns 1 through 12
Columns 13 through 24
Columns 37 through 48
Columns 49 through 60
Columns 61 through 72
Columns 73 through 84
Columns 85 through 96
>> y2=(2*cos(x1))+noice
y2 =
Columns 1 through 12
Columns 13 through 24
Columns 25 through 36
Columns 37 through 48
Columns 61 through 72
Columns 73 through 84
Columns 85 through 96