Main Program

You might also like

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

Main Program

% kasus 1
% Menghitung waktu pengisian tangki
clc
clear
% definisi global variabel
global Fin D d g
% input data
Fin=15/3600;
%m3/jam to m3/s
D=3;
%m
d=3/100;
%cm to m
g=10;
%m/s2
%batas integrasi
h=0,62;
%integrasi numeris
t=quadl(@integ_fun,0,h)
%tampilan dalam bentuk grafik
run_fun_ode

Subroutine
Function t=integ_fun(h)
global Fin D d g
A=pi*D^2/4;
A0=pi*d^2/4;
v=sqrt(2*g.*h);
Fout=A0*v;
t=A./(Fin-Fout);
Program menampilkan grafik
% permasalahn 1 dan 2
% menampilkan grafik h versus t
%input data
tf=12*3600;
% jam to s
[ts,hs]=ode45(@fun_ode, [0,tf],[0]);
plot(t/3600,h,'o',ts/3600,hs)
xlabel('waktu, jam')
ylabel('tinggi cairan,m')
legend('hasil hitungan','location','Best')
Subroutine
function dhdt=fun_ode(t,h)
global Fin D d g
A=pi*D^2/4;
A0=pi*d^2/4;
v=sqrt(2*g.*h);
Fout=A0*v;
dhdt=(Fin-Fout)/A;

Hasil

Grafik t versus h

1.8
1.6

tinggi cairan,m

1.4
1.2
1
0.8

hasil perhitungan

0.6
0.4
0.2
0

8
10
waktu,jam

12

14

16

18

You might also like