I.Listing Dan Pembahasan A.Perhitungan Matriks

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

I.

LISTING DAN PEMBAHASAN


A.PERHITUNGAN MATRIKS
>>A=[1 2 1 2; 3 5 4 6; 2 7 5 3]
A=
1
3
2

2
5
7

1
4
5

2
6
3

>> B=[1 3 4; 4 3 7; 2 3 9; 2 2 9]
B=
1
4
2
2

3
3
3
2

1
3
7

2
4
8

>> D=A.+C
??? D=A.+C
|
Error: Unexpected MATLAB operator.
>> D=A^2
??? Error using ==> mpower
Matrix must be square.

4
7
9
9

>> D=A.^2

>> C=[2 1 2 2; 3 3 4 5; 6 7 8 9]
C=
2
3
6

3 3 3 4
6 8 8 11
8 14 13 12

D=
1 4 1 4
9 25 16 36
4 49 25 9

2
5
9

>> D=A-2
>> D=A*B
D=
D=
-1
1
0

15 16 45
43 48 137
46 48 129

0 -1 0
3 2 4
5 3 1

>> D=2*A-1
>> D=B*A

D=

D=
18
27
29
26

45
72
82
77

33
51
59
55

32
47
49
43

>> D=A.*B
??? Error using ==> times
Matrix dimensions must agree.
>> D=A+C
D=

1 3 1 3
5 9 7 11
3 13 9 5

B. KONSTRUKSI LARIK
>> c=[b a]
c=

>> X=(0:0.1:1)*pi
X=

Columns 1 through 9
0 0.3142 0.6283 0.9425 1.2566
1.5708 1.8850 2.1991 2.5133

>> d=[a(1:2:5) 1 0 1]
d=
1

Columns 10 through 11
2.8274 3.1416

>> X=linspace(0,pi,11)
X=
Columns 1 through 9
0 0.3142 0.6283 0.9425 1.2566
1.5708 1.8850 2.1991 2.5133
Columns 10 through 11
2.8274 3.1416

>> X=logspace(0,2,11)
X=
Columns 1 through 9
1.0000 1.5849 2.5119 3.9811 6.3096
10.0000 15.8489 25.1189 39.8107
Columns 10 through 11
63.0957 100.0000

>> a=1:5, b=1:2:9


a=
1

b=
1

C. POLINOMINAL
>> P=[1 -12 0 25 116]
P=
1 -12

0 25 116

>> roots(P)
ans =
11.7473
2.7028
-1.2251 + 1.4672i
-1.2251 - 1.4672i
>> a=[1 2 3 4]
a=
1

>> b=[1 4 9 16]


b=
1

9 16

>> c=conv(a,b)
c=
1

6 20 50 75 84 64

>> polyval(c,[5])
ans =
55484

D. MENGGAMBAR GRAFIK 2D
>> x=(0:44/7:30)
x=
0 6.2857 12.5714 18.8571 25.1429
>> y=sin(x)
y=
0 0.0025 0.0051 0.0076 0.0101

>> w=[y;z];
>> plot(x,w)

>> x=linspace(0,44/7,30);
>> y=sin(x);
>> plot(x,y)

>> figure; plot(x,w)


>> plot(w,x)

>> z=cos(x);
>> plot(x,y,x,z)

>> x=linspace(0,2*pi,30);
>> y=sin(x);
>> z=cos(x);
>> plot(x,y,x,z);
>> grid

>>xlabel('variabel x bebas');

>>ylabel('variabel y bebas');

>>title('kurva sinus dan kosinus');

You might also like