Professional Documents
Culture Documents
Matlab 1
Matlab 1
NIM: 182140076
Kelas: 4C
1. Jika:
>> a=5;
>> b=15;
>> c=4;
>> d=a+b-c
d=
16
>> e=(b/a)+d*c
e=
67
>> f=a^c-b*e
f=
-380
>> g=sqrt(a*b*c)
g=
17.3205
>> h=(f/d)+(e-f)/a
h=
65.6500
>> a=[1 -3 -3 7 6]
a=
1 -3 -3 7 6
>> akar=roots(a)
akar =
3.0000
2.0000
-1.0000
-1.0000
3. Hitunglah transpose, determinan, dan invers (jika ada) dari matriks dibawah ini!
a. A = |12 35|
A=
1 3
2 5
>> A=A'
A=
1 2
3 5
>> det(A)
ans =
-1
>> inv(A)
ans =
-5 3
2 -1
b. B = |22 −13 |
B=
2 -1
1 3
>> B=B'
B=
2 1
-1 3
>> det(B)
ans =
>> inv(B)
ans =
0.4286 -0.1429
0.1429 0.2857
−2 4 0
c. C =
3 1 1
C=
-1 4 0
3 1 1
>> C=C'
C=
-1 3
4 1
0 1
>> det(C)
Error using det
Matrix must be square.
>> inv(C)
Error using inv
Matrix must be square.
5 −2 1
d. D = 3 4 2
−1 1 −3
D=
5 -2 1
3 4 2
-1 1 -3
>> D=D'
D=
5 3 -1
-2 4 1
1 2 -3
>> det(D)
ans =
-77.0000
>> inv(D)
ans =
A=
2 3
-1 4
>> B= [5;2]
B=
5
2
>> inv(A)
ans =
0.3636 -0.2727
0.0909 0.1818
>> inv(A)*B
ans =
1.2727
0.8182
b. -2x +y = 5; 3x + 2y = -1
>> A= [-2 1;3 2]
A=
-2 1
3 2
>> B= [2;-1]
B=
2
-1
>> inv(A)
ans =
-0.2857 0.1429
0.4286 0.2857
>> inv(A)*B
ans =
-0.7143
0.5714
c. 2x –y + 2x =5; -x + 2y –z = 6;2x – 2y + 3z = 4
>> A=[2 -1 2; -1 2 -1;2 -2 3]
A=
2 -1 2
-1 2 -1
2 -2 3
>> B= [5;6;4]
B=
5
6
4
>> inv(A)
ans =
>> inv(A)*B
ans =
0.6667
5.6667
4.6667
d. x + y + z = 3; 3x – y + 2z = 4; 2x + 3y - z = 1
>> A= [1 1 1; 3 -1 2;2 -2 3]
A=
1 1 1
3 -1 2
2 -2 3
>> B = [3;4;1]
B=
3
4
1
>> inv(A)
ans =
>> inv(A)*B
ans =
1.7500
1.2500
0.0000
e. x + y + z = 2; 3x – y + 2z = 4; 2x + 3y + z = 7
>> A= [1 1 1;3 -1 2;2 3 1]
A=
1 1 1
3 -1 2
2 3 1
>> B= [2;4;7]
B=
2
4
7
>> inv(A)
ans =
-1.4000 0.4000 0.6000
0.2000 -0.2000 0.2000
2.2000 -0.2000 -0.8000
>> inv(A)*B
ans =
3.0000
1.0000
-2.0000
f.x + 2y + z = 4;x + 5y – 3z = 2; 2z + 7y – z = 5
>> A=[1 2 1;1 5 -3;2 7 -1]
A=
1 2 1
1 5 -3
2 7 -1
>> B= [4;2;5]
B=
4
2
5
>> inv(A)
ans =
>> inv(A)*B
ans =
9
-2
-1
1 1 -2
>> akar=roots(a)
akar =
-2
1
b. 2x2 – x – 1 = 0
>> b= [2 -1 -1]
b=
2 -1 -1
>> akar=roots(b)
akar =
1.0000
-0.5000
c. - 6x2 + 7x - 2 = 0
>> c= [-6 7 -2]
c=
-6 7 -2
>> akar=roots(c)
akar =
0.6667
0.5000
d. - 6x2 – 7x + 3 = 0
>> d= [-6 -7 3]
d=
-6 -7 3
>> akar=roots(d)
akar =
-1.5000
0.3333
e. X3 – x2 – 4x + 4 = 0
>> e= [1 -1 -4 4]
e=
1 -1 -4 4
>> akar=roots(e)
akar =
-2.0000
2.0000
1.0000
f.6x3 + x2 – 10x + 3 = 0
>> f= [6 1 -10 3]
f=
6 1 -10 3
-1.5000
1.0000
0.3333
g. 6x3 – 7x2 – x + 2 = 0
>> g= [6 -7 -1 2]
g=
6 -7 -1 2
-0.5000
1.0000
0.6667
-12 32 -25 6
i.X3 – 3x + 1 = 0
>> i= [1 0 -3 1]
i=
1 0 -3 1
-1.8794
1.5321
0.3473
6 13 -12 -17 6
-2.4419
-1.1656
1.1298
0.3110