You are on page 1of 9

diary on

%soal no 1
R1=5;
R2=10;
R3=5;
R4=15;
R5=10;
R6=20;
Va=200;
Vb=0;
fschange('D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\soal_1a.m');
clear soal_1a
uiopen('D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\gauss.m',1)
%soal no 1
%metode gauss
A=[15 5 10 -10;20 10 5 0]
A =
15
20

5
10

10
5

-10
0

b=[0;-200]
b =
0
-200
gauss(A,b)
??? Index exceeds matrix dimensions.
Error in ==> <a href="error:D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\g
auss.m,7,1">gauss at 7</a>
m=-A(i+1:n,i)/A(i,i);
%metode jacobi
A=[15 5 10 -10;20 10 5 0]
A =
15
20
b=[0;-200]

5
10

b =
0
-200
x0=[1;1]
x0 =
1

10
5

-10
0

1
tol=10e-6
tol =
1.0000e-005
maks=50
maks =
50
uiopen('D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\jacobian.m',1)
jacobian(A,b,x0,maks)
ans =
19.9992
-59.9976
uiopen('D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\gauss_seidel.m',1)
%metode gauss_seidel
A=[15 5 10 -10;20 10 5 0]
A =
15
20

5
10

10
5

-10
0

b=[0;-200]
b =
0
-200
x0=[1;1]
x0 =
1
1
tol=10e-6
tol =
1.0000e-005
maks=50
maks =
50
gauss_seidel(A,b,x0,tol,maks)
f x1 x2 x3 ...
??? Error using ==> mtimes

Inner matrix dimensions must agree.


Error in ==> <a href="error:D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\g
auss_seidel.m,17,1">gauss_seidel at 17</a>
x(j)=C(j,:)*x+r(j);
%metode SOR
uiopen('D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\SOR.m',1)
A=[15 5 10 -10;20 10 5 0]
A =
15
20

5
10

10
5

-10
0

b=[0;-200]
b =
0
-200
x0=[1;1]
x0 =
1
1
tol=10e-6
tol =
1.0000e-005
maks=50
maks =
50
fschange('D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\SOR.m');
clear sor
w=1.75
w =
1.7500
SOR(A,b,x0,w,tol,maks)
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> <a href="error:D:\Kuliah\Semester V\Komputasi Fisika\UTS bagian 2\S
OR.m,15,1">SOR at 15</a>
x(j)=(1-w)*xlama(j)+w*(C(j,:)*x+r(j));
% soal nomor 2
uiopen('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar KS_UTS2\tpalsu.m',1)
uiopen('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar KS_UTS2\newt.m',1)

uiopen('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar KS_UTS2\secant.m',1)


uiopen('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar KS_UTS2\soal_2.m',1)
uiopen('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar KS_UTS2\soal_2diff.m',1)
% metode bagi dua
bagidua('soal_2',2,4,10e-6)
f =
9
f =
77
ans =
[]
% metode posisi palsu
tpalsu('soal_2',2,4,10e-6)
f =
9
fa =
9
f =
77
fb =
77
ans =
[]
% metode newton raphson
newt('soal_2','soal_2diff',2,10e-6,10)
f =
9
f =
16

iter =
0
f =
2.0369
f =
9.0742
f =
0.2564
f =
6.8404
f =
0.0065
f =
6.4969
f =
4.4791e-006
f =
6.4879
f =
2.1574e-012
metode newton telah korvergen
ans =
2.0000
1.4375
1.2130
1.1756
1.1746
1.1746

% metode secant
secant('soal_2',2,4,10e-6,10)
f =
9
f =
77
f =
5.2366
f =
3.3352
f =
0.7369
f =
0.1544
f =
0.0105
f =
1.6994e-004
f =
1.9224e-007
f =
3.5114e-012
metode newton telah konvergen
ans =
2.0000
4.0000
1.7353
1.5700

1.2802
1.1980
1.1762
1.1746
1.1746
1.1746
% kesimpulan : dengan menggunakan metode biseksi, posisi palsu, newton raphson,
dan secant dapat dismpulkan bahwa benda tersebut melewati titik asalnya setelah
menempuh waktu 1,1746 s
% soal no 1
% metode eliminasi gauss
uiopen('D:\matlab\MATLAB
uiopen('D:\matlab\MATLAB
)
uiopen('D:\matlab\MATLAB
uiopen('D:\matlab\MATLAB
A=[0 10 5 15 -10 0;5 0 0
b=[0;200;0];
gauss(A,b)
??? Index exceeds matrix

7\120210102027_Defrin Yuniar KS_UTS2\gauss.m',1)


7\120210102027_Defrin Yuniar KS_UTS2\gauss_seidal.m',1
7\120210102027_Defrin Yuniar KS_UTS2\jacobian.m',1)
7\120210102027_Defrin Yuniar KS_UTS2\SOR.m',1)
0 10 20;-1 1 1 1 1 1];
dimensions.

Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar KS_UT


S2\gauss.m,7,1">gauss at 7</a>
m=-A(i+1:n,i)/A(i,i);
A=[0 10 5 15 -10 0;5 0 0 0 10 20;-1 1 1 1 1 1];
b=[0;200;0];
x0=2;
maks=5;
jacobian(A,b,x0,maks)
??? Index exceeds matrix dimensions.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar KS_UT
S2\jacobian.m,6,1">jacobian at 6</a>
S=b(j)-A(j,[1:j-1,j+1:n])*x0([1:j-1,j+1:n]);
A=[0 10 5 15 -10 0;5 0 0 0 10 20;-1 1 1 1 1 1];
b=[0;200;0];
% soal no 3
% menghitung nilai n dan p terlebih dahulu
m=1.2*10^6
m =
1200000
c=1.4*10^7;
x0=0.3;
k=1.25*10^9;
n=(k/m-(c^2-4*m^2))^1/2
n =

-9.5120e+013
p=c/2*m
p =
8.4000e+012
fschange('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.m');
clear soal_3
% metode bagi dua
bagidua('soal_3',2,3,10e-6)
??? Error: File: D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.
m Line: 2 Column: 20
Missing MATLAB operator.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\bagidua.m,3,1">bagidua at 3</a>
fa=feval(f,a);
fschange('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.m');
clear soal_3
bagidua('soal_3',2,3,10e-6)
??? Error: File: D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.
m Line: 2 Column: 74
This statement is incomplete.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\bagidua.m,3,1">bagidua at 3</a>
fa=feval(f,a);
fschange('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.m');
clear soal_3
bagidua('soal_3',2,3,10e-6)
??? Error: File: D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.
m Line: 2 Column: 76
This statement is incomplete.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\bagidua.m,3,1">bagidua at 3</a>
fa=feval(f,a);
fschange('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.m');
clear soal_3
bagidua('soal_3',2,3,10e-6)
??? Undefined function or variable 'e'.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\soal_3.m,2,1">soal_3 at 2</a>
f=e^-((-n)*x)*((m*cos*p*x)+(m*sin*p*x))
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\bagidua.m,3,1">bagidua at 3</a>
fa=feval(f,a);
fschange('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.m');
clear soal_3
bagidua('soal_3',2,3,10e-6)
??? Undefined function or variable 'e'.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U

TS2\soal_3.m,2,1">soal_3 at 2</a>
f=e^-((--9.5120e+013)*x)*((1200000*cos*8.4000e+012*x)+(1200000*sin*8.4000e+012*x
))
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\bagidua.m,3,1">bagidua at 3</a>
fa=feval(f,a);
fschange('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.m');
clear soal_3
bagidua('soal_3',2,3,10e-6)
??? Undefined function or variable 'e'.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\soal_3.m,2,1">soal_3 at 2</a>
f=e^-((-9.5120e+013)*x)*((1200000*cos*8.4000e+012*x)+(1200000*sin*8.4000e+012*x)
)
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\bagidua.m,3,1">bagidua at 3</a>
fa=feval(f,a);
fschange('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.m');
clear soal_3
bagidua('soal_3',2,3,10e-6)
??? Undefined function or variable 'e'.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\soal_3.m,2,1">soal_3 at 2</a>
f=e^9.5120e+013*x*((1200000*cos*8.4000e+012*x)+(1200000*sin*8.4000e+012*x))
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\bagidua.m,3,1">bagidua at 3</a>
fa=feval(f,a);
tpalsu('soal_3',2,3,10e-6)
??? Undefined function or variable 'e'.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\soal_3.m,2,1">soal_3 at 2</a>
f=e^9.5120e+013*x*((1200000*cos*8.4000e+012*x)+(1200000*sin*8.4000e+012*x))
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\tpalsu.m,3,1">tpalsu at 3</a>
fa=feval(f,a)
fschange('D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.m');
clear soal_3
bagidua('soal_3',2,3,10e-6)
??? Error: File: D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_UTS2\soal_3.
m Line: 2 Column: 5
Incomplete or misformed expression or statement.
Error in ==> <a href="error:D:\matlab\MATLAB 7\120210102027_Defrin Yuniar K.S_U
TS2\bagidua.m,3,1">bagidua at 3</a>
fa=feval(f,a);
diary off

You might also like