Professional Documents
Culture Documents
Tugas Prokom
Tugas Prokom
FAKULTAS TEKNIK
UPN “VETERAN” JAWA TIMUR Nama : MOH AUFAL WIDAD
NPM/Semester : 19031010219/1
Praktikum : PROGRAM KOMPUTER Sesi :3
Percobaan : MATRIX DAN PLOT DALAM Paralel :E
PEMROGRAMAN MATLAB
Tanggal : 12 NOVEMBER 2019
Pembimbing : NOVE KARTIKA E., ST, MT
LAPORAN RESMI
1. Explain about matrix and plot (2 and 3 Dimension) that you know in
matlab! Mention the types and their requirement!
2. Make your program in matlab with input, output, selection statement,
looping, and matrix or plot! Give your algorithm, flowchart, and
printscreen about input & output! Be creative!
3. Create your own program with new statement outside modul and describe
why you need that statement!
4 1 2𝑁𝑃𝑀 𝐴𝑘ℎ𝑖𝑟 3 2 3
𝐴=[ 8 6 7 ] 𝐵 = [ 9 3 2]
2𝑁𝑃𝑀 𝐴𝑤𝑎𝑙 3 6 7 1 4
Determine the inverse matrix C value using the matlab program, display the
script and run the results. also include the manual calculation !
By using C = AT x B
start
Menginput
kan pilihan
Memasukkan m
Case 1 (massa),v(kecepatan), i
(interval)
For
x=m:i:b
Menghitung ek=½*m*v^2
Menampilkan m
(massa),v(kecepatan),
ek(energi kinetik)
m=m+i
A B
A B
Memasukkan m
Case 2 (massa), h (tinggi), i
(interval)
no
While
m<=100
yes
Menghitung
ep=m*g*h
Menampilkan m
(massa), h (tinggi), g
(Percepatan
gravitasi),ep (Energi
potensial)
m=m+i
end
Script:
clear all;
clc;
disp ('Energy calculation program');
disp ('1. kinetic energy');
disp ('2. potential energy');
pill = input ('enter selection =');
pill switch case (1) clc;
disp ('kinetic energy calculation program');
m = input ('enter mass =');
v = input ('enter speed =');
i = input ('enter interval =');
ba = input ('enter the deadline =');
fprintf ('% 9s% 9s% 9s \ n', 'm', 'v', 'oak');
for m = m: i: ba
ek = 1/2 * m * v ^ 2;
fprintf ('% 10.1f% 10.1f% 10.1f \ n', m, v, ek);
m = m + i;
end
case (2)
clc;
m = input ('mass =');
h = input ('height =');
g = 9.8;
disp ('g = 9.8');
i = input ('enter interval =');
fprintf ('% 9s% 9s% 9s% 9s \ n', 'm', 'g', 'h', 'ep');
while m <= 100
ep = m * g * h;
fprintf ('% 10.2f% 10.2f% 10.2f% 10.2f \ n', m, g, h, ep);
m = m + i;
end
otherwise
disp ('no options');
end
Run result:
3. Create your own program with new statement outside modul and describe
why you need that statement!
Algorithm:
1. Start the program
2. Insert mass (m)
3. Entering speed (v)
4. Entering intervals (i)
5. Repeating mass (m)
6. Calculate kinetic energy with the formula:
ek = ½ * m * v ^ 2
7. Displays m (mass), v (velocity), ek (kinetic energy)
8. The program is complete
Flowchart:
start
Memasukkan m
(massa),v(kecepat
an), i (interval)
No
While
m<=100
yes
Menghitung
ek=½*m*/v^2
Menampilkan m
(massa),v(kecepat
an),ek(Energi
kinetik)
m=m+i
end
Script:
clear all;
clc;
disp ('###############################');
disp ('kinetic energy calculation');
disp ('###############################');
disp ('');
m = input ('enter mass =');
v = input ('enter speed =');
i = input ('enter interval =');
disp ('');
fprintf ('% 9s% 14s% 20s \ n', 'mass', 'velocity', 'kinetic energy');
disp ('=============================================== ======
');
while m <= 100
disp (‘m’);
break
disp (‘program dicekal’);
ek = 1/2 * m * v ^ 2;
fprintf ('% 8.1f% 12.1f% 20.1f \ n', m, v, ek);
m = m + i;
end
Run result :
I choose to use kind of statement in matlab outside modul it’s break statement.
I use this statement because in my program there is a looping and the function of
break statement is to go to stop looping in iteration early, other than this statement
has function to stop iteration without continue the looping. Therefore, I very need
this statement in order to applied in my program.
4 1 19 3 2 3
4. 𝐴 = [ 8 6 7 ] 𝐵 = [9 3 2] Determine the invers matrix C, by
21 3 6 7 1 4
using C = AT x B
a. Script :
clear all:
clc;
a=[4 1 19; 8 6 7; 21 3 6]
b=[3 2 3; 9 3 2; 7 1 4]
c=a'*b
b. Run result :
c. Manual calculation
C = AT x B
4 8 19 3 2 3
= [ 1 6 3 ] x [ 9 3 2]
21 7 6 7 1 4
12 + 72 + 133 8 + 24 + 19 12 + 16 + 76
= [ 3 + 54 + 21 2 + 18 + 3 3 + 12 + 12 ]
63 + 63 + 42 42 + 21 + 6 63 + 14 + 24
217 51 104
C = [ 78 23 27 ]
168 69 101
1
C-1 = det 𝐶 Adj C
217 51 104 217 51
Det C = [ 78 23 27 ] 78 23
168 69 101 168 69
= (504.091+231.336+796.536)-(401.856 +404.271+401.778)
= (1.531.963) – (1.207.905)
= 324.058
Adj C = CT
23 27 51 104 51 104
K11 = [ ] K21 = [ ] K31 = [ ]
69 101 69 101 23 27
= 460 =2.025 = -1.015
78 27 217 104 217 104
K12 = [ ] K22 = [ ] K32 = [ ]
168 101 168 101 78 27
= 3.342 =4.445 = -2.253
78 23 217 51 217 51
K13 = [ ] K23 = [ ] K33 = [ ]
168 69 168 69 78 23
= 1.518 = 6.405 = 1.013