Unit 1 (19092011)
Unit 1 (19092011)
1. Operator Komputasi
>> A=10;
>> B=5;
>> A+B
ans =
15
>> A-B
ans =
5
>> A*B
ans =
50
>> A/B
ans =
2
>> B\A
ans =
2
>> A^B
ans =
100000
2. Bilangan Kompleks
>> a=4+3i;
>> real(a)
ans =
4
>> imag (a)
ans =
3
>> abs (a)
ans =
5
>> angle (a)
ans =
0.6435
>> conj (a)
ans =
4.0000 - 3.0000i
3. Fungsi Matematis
>> x=pi/3
x=
1.0472
>> a=0.01
a=
0.0100
>> acos (a)
ans =
1.5608
>> acosh (a)
ans =
0 + 1.5608i
>> asin (a)
ans =
0.0100
>> atan (a)
ans =
0.0100
>> ceil(x)
ans =
2
>> exp(x)
ans =
2.8497
>> cos (x)
ans =
0.5000
>> fix(x)
ans =
1
>> floor(x)
ans =
1
>> log(x)
ans =
0.0461
>> log10(x)
ans =
0.0200
>> rem(x,a)
ans =
0.0072
>> round(x)
ans =
1
>> sin(x)
ans =
0.8660
>> sqrt(x)
ans =
1.0233
>> tan(x)
ans =
1.7321
4. Variable
>> p=10;
>> l=5;
>> L=p*l
L=
50
UNIT 2
1. Pembentukan Aray
>> x=(0:0.1:1) *pi
x=
Columns 1 through 5
0 0.3142 0.6283 0.9425 1.2566
Columns 6 through 10
1.5708 1.8850 2.1991 2.5133 2.8274
Column 11
3.1416
>> x=linspace(0,pi,11)
x=
Columns 1 through 5
0 0.3142 0.6283 0.9425 1.2566
Columns 6 through 10
1.5708 1.8850 2.1991 2.5133 2.8274
Column 11
3.1416
>> M=logspace(0,2,11)
M=
Columns 1 through 5
1.0000 1.5849 2.5119 3.9811 6.3096
Columns 6 through 10
10.0000 15.8489 25.1189 39.8107 63.0957
Column 11
100.0000
>> x=[2 2*pi sqrt(2) 2-3j]
x=
Columns 1 through 2
2.0000
6.2832
Columns 3 through 4
1.4142
2.0000 - 3.0000i
8 10
>> y(1:2:8)
ans =
1
9 13
>> x(1:3:10)
ans =
0
6 12 18
>> y^2
??? Error using ==> mpower
Matrix must be square.
>> y.^2
ans =
Columns 1 through 8
1
Columns 9 through 11
289 361 441
>> x.^2
ans =
Columns 1 through 8
0
Columns 9 through 11
256 324 400
>> y./2
ans =
Columns 1 through 5
0.5000 1.5000 2.5000 3.5000 4.5000
Columns 6 through 10
>> A(2,:)
ans =
4
>> A(:,3)
ans =
3
6
9
3. Matematika Aray
>> a=[2 4 3 5 7]
a=
2
8 10 12
>> d=a+b
??? Error using ==> plus
Matrix dimensions must agree.
>> e=b-2
e=
-1
0
1
2
3
>> f=b*3
f=
3
6
9
12
15
>> g=b/2
g=
0.5000
1.0000
1.5000
2.0000
2.5000
>> h=a./b
??? Error using ==> rdivide
Matrix dimensions must agree.
>> h=a/b
??? Error using ==> mrdivide
Matrix dimensions must agree.
>> k=a.\b
??? Error using ==> ldivide
Matrix dimensions must agree.
>> x=a*b
x=
74
>> y=b*a
y=
2
4
6
8
10
4
8
12
16
20
3 5 7
6 10 14
9 15 21
12 20 28
15 25 35
>> z=a.*b
??? Error using ==> times
Matrix dimensions must agree.
4. Matriks
>> m_eye = eye(4)
m_eye =
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
2
5
8
3
6
0
>> b=[366;804;351]
b=
366
804
351
>> det(A)
ans =
27
>> x=inv(A)*b
x=
25.0000
22.0000
99.0000
>> x=A\b
x=
25.0000
22.0000
99.0000
5. Ukuran Aray
>> A=[1 2 3 4;5 6 7 8]
A=
1
5
2
6
3
7
4
8
>> s=size(A)
s=
2
>> [r,c]=size(A)
r=
2
c=
4
>> r=size(A,1)
r=
2
>> c=size(A,2)
c=
4
>> length(A)
ans =
4