Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Tugas 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Nama : Darmulyani

Nim : 60400118012
Kelas : Fisika C
TUGAS 3
Halaman 43-44
Tugas (Latihan Pemrograman_4)
1. >> g=[4 2 10;1 8 2;2 1 50];
>> h=[20 50 100;20 38 20;10 23 50];
a. >> g+h
ans =
24 52 110
21 46 22
12 24 100
b. >> g-h
ans =
-16 -48 -90
-19 -30 -18
-8 -22 0
c. >> 2*g+3*h
ans =
68 154 320
62 130 64
34 71 250
d. >> 2*(g+h)
ans =
48 104 220
42 92 44
24 48 200
e. >> g^2+h^2
ans =
2438 5234 8544
1376 2972 3886
1269 2586 6482
f. >> 3*g*(2*g+2*h)
ans =
1548 3240 8904
1296 2808 2916
4014 8100 31452

g. >> h/g
ans =
3.0815 5.3333 1.1704
4.3793 3.7333 -0.6252
1.6089 2.4000 0.5822
h. >> (2*h/2*g)/(h+g)
ans =
-32.3810 2.3810 88.0952
28.4974 -16.4974 -14.9577
-23.2751 5.2751 50.9021
i. >> h\2*g
ans =
1.0e+003 *
0.1650 0.2700 2.6500
0.0790 0.1820 0.6380
0.0815 0.1270 1.3230
2. Tentukan matriks berikut
a. >> zeros(5)
ans =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
b. >> zeros(3)+pi
ans =
3.1416 3.1416 3.1416
3.1416 3.1416 3.1416
3.1416 3.1416 3.1416
c. >> eye(4)
ans =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
d. >> ones(6)
ans =
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1

3. Dari matriks nomor 1 di atas, hitunglah:


>> A=[4 2 10;1 8 2;2 1 50];
>> B=[20 50 100;20 38 20;10 23 50];
a. >> det(A)
ans =
1350
>> det(B)
ans =
-3200
>> inv(A)
ans =
0.2948 -0.0667 -0.0563
-0.0341 0.1333 0.0015
-0.0111 0 0.0222
>> inv(B)
ans =
-0.4500 0.0625 0.8750
0.2500 0 -0.5000
-0.0250 -0.0125 0.0750
b. >> A'
ans =
4 1 2
2 8 1
10 2 50
>> B'
ans =
20 20 10
50 38 23
100 20 50
c. >> eig(A)
ans =
50.4869
3.2271
8.2860
>> eig(B)
ans =
95.0161
-2.2157
15.1996
4. >> ABC=[2 -1 4;2 1 -7;2 -1 6];
>> K=[10;20;10];
>> xyz=inv(ABC)*K
xyz =
7.5000
5.0000
0
5. >> A=[10 20 30;40 50 60;70 80 100]
A=
10 20 30
40 50 60
70 80 100
>> B=[100;200;150]
B=
100
200
150
>> y=inv(A)*B
y=
-18.3333
36.6667
-15.0000
>> y=A\B
y=
-18.3333
36.6667
-15.0000
>> [L,U]=lu(A)
L=
0.1429 1.0000 0
0.5714 0.5000 1.0000
1.0000 0 0
U=
70.0000 80.0000 100.0000
0 8.5714 15.7143
0 0 -5.0000
>> y=inv(U)*inv(L)*B
y=
-18.3333
36.6667
-15.0000
6. >> A=[10 20 30;40 50 60;70 80 100];
>> B=[100;200;150];
>> det(A)
ans =
-3000
>> inv(A)
ans =
-0.0667 -0.1333 0.1000
-0.0667 0.3667 -0.2000
0.1000 -0.2000 0.1000
>> eig(A)
ans =
167.0749
-9.0574
1.9825
7. >> 'A=[2 3 4;6 7 8;5 3 7]'
ans =
A=[2 3 4;6 7 8;5 3 7]
a. >> A'
ans =
2 6 5
3 7 3
4 8 7
b. >> det(A)
ans =
-24
c. >> inv(A)
ans =
-1.0417 0.3750 0.1667
0.0833 0.2500 -0.3333
0.7083 -0.3750 0.1667
d. >> eig(A)
ans =
14.8839
-0.8290
1.9451

You might also like