Sei sulla pagina 1di 32

PROJECT

(SAMPLE APPLICATION PROGRAM OF MECHANICS FORMULA)

COMPILED BY:

Name : Nur Aini


Id : 4163322004
Class : Bilingual Physics Education 2016
Course : Algorithm And Programming
Lecturer : Prof.Dr.H.Sahyar, M.S., M.M.

PHYSICS DEPARTMENT
FACULTY OF MATHEMATICS AND NATURAL SCIENCE
STATE UNIVERSITY OF MEDAN
2018
1. Program to Determine Kinetic Energy
1. Definition of Problem
 Determine kinetic Energy
 Formula: Ek=0.5*m*v2
 Data input: velocity, mass.
 Output Data: kinetic Energy
2. Data Structure
Unit/Magnitude Variable Type of data Description
Velocity v Real/Numeric Input data
Mass m Real/Numeric Input data
Kinetic Energy ke Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

v,m

ke = 0.5*m*v

ke

Stop

4. Coding In MatLab
%Program Computer to Determine Kinetic Energy
%Input
v=input ('velocity= ' );
m=input ('mass= ' );
%process
ke=0.5*m*v.^2;
%output
fprintf( '\nKinetic Energy=%8.2f' ,ke) ;disp([ ' joule']);
5. Testing Program
>> test 1
velocity= 42
mass= 30
Kinetic Energy=26460.00 joule

>> test 2
velocity= 30
mass= 30
Kinetic Energy=13500.00 joule

>> test 3
velocity= 23
mass= 4
Kinetic Energy= 1058.00 joule

2. Program to Determine Debit Fluid


1. Definition of Problem
 Determine Debit Fluid
 Formula: Q=v/t
 Data input: volume, time.
 Output Data: Debit Fluid

2. Data Structure

Unit/Magnitude Variable Type of data Description


Volume v Real/Numeric Input data
Time t Real/Numeric Input data
Debit Fluid Q Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

v, t

Q=v/t
Q

Stop

4. Coding In MatLab
%Program Computer to Determine debit fluid
%Input
v=input ('volume= ' );
t=input ('time= ' );
%process
ke=v/t;
%output
fprintf( '\nDebit Fluid=%8.1f' ,ke) ;disp([ ' Liter/sekon']);

5. Testing Program
>> test 1
volume= 300
time= 56
Debit Fluid= 5.4 Liter/sekon

>> test 2
veolume= 150
time= 20
Debit Fluid= 7.5 Liter/sekon

>> test 3
veolume= 100
time= 12
Debit Fluid= 8.3 Liter/sekon

3. Program to Determine Implus


1. Definition of Problem
 Determine of Implus
 Formula: I=F*t
 Data input: Force, time.
 Output Data: Implus
2. Data Structure

Unit/Magnitude Variable Type of data Description


Force F Real/Numeric Input data
Time t Real/Numeric Input data
Implus I Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

F, t

I=F*t

Stop

4. Coding In MatLab
%Program Computer to Determine Implus
%Input
f=input ('Force = ' );
t=input ('time = ' );
%process
I=f*t;
%output
fprintf( '\nImplus=%8.1f' ,I) ;disp([ ' Newton/sekon']);

5. Testing Program
>> test 1
Force = 30
time = 2
Implus= 60.0 Newton/sekon

>> test 2
Force = 40
time = 2
Implus= 80.0 Newton/sekon

>> test 3
Force = 20
time = 43
Implus= 860.0 Newton/sekon

4. Program to Determine distance of Accelerated Linier Motion


1. Definition of Problem
 Determine of Distance.
 Formula: d=vo*t+0.5*a*t.^2
 Data input: Initial velocity, time, accelaration.
 Output Data: Distance

2. Data Structure

Unit/Magnitude Variable Type of data Description


Initial velocity Vo Real/Numeric Input data
Time T Real/Numeric Input data
acceleration a Real/numeric Input data
direction d Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

Vo, t, a

d= vo *t+0.5*a*t.^2

d
Stop

4. Coding In MatLab
%Program Computer to Determine Distance
%Input
vo=input ('Initial velocity = ' );
a=input ('accelaration = ' );
t=input ('time = ' );
%process
d=vo*t+0.5*a*t.^2;
%output
fprintf( '\ndistance=%8.1f' ,d) ;disp([ ' meter']);

5. Testing Program
>> test 1
Initial velocity = 0
accelaration = 30
time = 2
distance= 60.0 meter

>> test 2
Initial velocity = 20
accelaration = 2
time = 10
distance= 300.0 meter

>> test 3
Initial velocity = 24
accelaration = 3
time = 20
distance= 1080.0 meter

5. Program to Determine velocity


1. Definition of Problem
 Determine of Velocity
 Formula: v=s/t
 Data input: direction, time.
 Output Data: Distance
2. Data Structure

Unit/Magnitude Variable Type of data Description


distance s Real/Numeric Input data
time t Real/Numeric Input data
velocity v Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

s,t

V=s/t

Stop

4. Coding In MatLab
%Program Computer to Determine velocity
%Input
s=input ('direction = ' );
t=input ('time = ' );
%process
v=s/t;
%output
fprintf( '\nvelocity=%8.1f' ,v) ;disp([ ' m/s']);

5. Testing Program
>> test 1
direction = 20
time = 5
velocity= 4.0 m/s

>> test 2
direction = 300
time = 6
velocity= 50.0 m/

>> test 3
direction = 40
time = 3
velocity= 13.3 m/s

6. Program to Determine Torque


1. Definition of Problem
 Determine of Torque
 Formula: 𝜏 = 𝑟 ∗ 𝐹𝑠𝑖𝑛𝜃
 Data input: radius, force, sinus.
 Output Data: Distance

2. Data Structure

Unit/Magnitude Variable Type of data Description


radius r Real/Numeric Input data
force f Real/Numeric Input data
Sinus alfa Sin(x) Real/Numeric Input data
torque tr Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

r, f, sin(x)

Tr = r*f*sin(x)

tr
Stop

4. Coding In MatLab
%Program Computer to Torque
%Input
r=input ('radius = ' );
f=input ('force = ' );
x=input ('alfa = ' );
%process
x=x*pi/180;
tr=r*f*sin(x);
%output
fprintf( '\nTorque=%8.1f' ,tr) ;disp([ ' Nm']);

5. Testing Program
>> test 1
radius = 4
force = 2
alfa = 15
Torque= 2.1 Nm

>> test 2
radius = 6
force = 4
alfa = 45
Torque= 17.0 Nm

>> test 3
radius = 8
force = 12
alfa = 30
Torque= 48.0 Nm

7. Program to Determine Maximum Distance


1. Definition of Problem
 Determine of maximum distance
𝑉𝑜 ∗𝑠𝑖𝑛2𝛼
 Formula : 𝑋𝑚𝑎𝑥 = 𝑔
 Data input: initial velocity,sinus,gravity
 Output Data: Calor
2. Data Structure

Unit/Magnitude Variable Type of data Description


Initial velocity Vo Real/Numeric Input data
Sinus sudut Sin(x) Real/Numeric Input data
Gravity g Real/Numeric Input data
Maximum distance dmax Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

Vo, sin(x), g

dmax= vo*(sin(2*x))/g

dmax

Stop

4. Coding In MatLab
%Program Computer to Determine maximum distance
%Input
vo=input ('initial velocity = ' );
x=input ('alfa = ' );
%process
x=x*pi/180;
g=10;
dmax=vo*(sin(2*x))/g;
%output
fprintf( '\nmaximum distance=%8.1f' ,dmax) ;disp([ 'm']);
5. Testing Program
>> test 1
initial velocity = 3
alfa = 15
maximum distance= 0.1m

>> test 2
initial velocity = 4
alfa = 45
maximum distance= 0.4m

>> test 3
initial velocity = 6
alfa = 30
maximum distance= 0.5m

8. Program to Determine statis friction


1. Definition of Problem
 Determine of statis friction
 Formula: 𝑓𝑠 = 𝜇𝑠 ∗ 𝑁
 Data input: coefficient of friction, Normal Force
 Output Data: Distance

2. Data Structure

Unit/Magnitude Variable Type of data Description


Normal Force N Real/Numeric Input data
coefficient of c Real/Numeric Input data
friction
Statis friction fs Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

c, n

Fs = c*n
fs

Stop

4. Coding In MatLab
%Program Computer to Statis Friction
%Input
c=input ('coefficient of friction = ' );
n=input ('normal force = ' );
%process
fs=c*n;
%output
fprintf( '\nstatis friction=%8.1f' ,fs) ;disp([ ' N']);

5. Testing Program
>> test 1
coefficient of friction = 32
normal force = 30
statis friction= 960.0 N

>> test 2
coefficient of friction = 20
normal force = 5
statis friction= 100.0 N

>> test 3
coefficient of friction = 50
normal force = 67
statis friction= 3350.0 N

9. Program to Determine Hidrostatic Pressure


1. Definition of Problem
 Determine of hydrostatic pressure
 Formula: 𝑃 = 𝜌 ∗ 𝑔 ∗ ℎ
 Data input: density ,height
 Output Data: Pressure
2. Data Structure

Unit/Magnitude Variable Type of data Description


density d Real/Numeric Input data
height h Real/Numeric Input data
pressure P Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

d, h

P=d*g*h

Stop

4. Coding In MatLab
%Program Computer to Pressure
%Input
d=input ('density = ' );
h=input ('height = ' );
%process
g=10;
P=d*g*h;
%output
fprintf( '\nPressure=%8.1f' ,P) ;disp([ ' Pa']);
5. Testing Program
>> test 1
density = 30
height = 15
Pressure= 4500.0 Pa

>> test 2
density = 20
height = 14
Pressure= 2800.0 Pa

>> test 3
density = 30
height = 40
Pressure= 12000.0 Pa

10. Program to Determine mechanic Energy


1. Definition of Problem
 Determine of mechanic energy
 Formula: 𝐸𝑚 = 𝑚 ∗ 𝑔 ∗ ℎ + 0.5 ∗ 𝑚 ∗ 𝑣. ^2
 Data input: mass, gravity, height, velocity
 Output Data: Energy Mechanic

2. Data Structure

Unit/Magnitude Variable Type of data Description


mass m Real/Numeric Input data
height h Real/Numeric Input data
velocity v Real/Numeric Input data
pressure P Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

m, h, v

𝑚𝑒 = 𝑚 ∗ 𝑔 ∗ ℎ + 0.5 ∗ 𝑚 ∗ 𝑣. ^2
me

Stop

4. Coding In MatLab
%Program Computer to Mechanic Energy
%Input
m=input ('mass= ' );
h=input ('height = ' );
v=input ('velocity = ' );
%process
g=10;
me=m*g*h+0.5*m*v.^2;
%output
fprintf( '\nMechanic Energy=%8.1f' ,me) ;disp([ ' Joule']);

5. Testing Program
>> test 1
mass= 10
height = 5
velocity = 3
Mechanic Energy= 545.0 Joule

>> test 2
mass= 10
height = 9
velocity = 43
Mechanic Energy= 10145.0 Joule

>> test 3
mass= 45
height = 110
velocity = 30
Mechanic Energy= 69750.0 Joule
11. Program to Determine Period of Pendulum
1. Definition of Problem
 Determine of Period of Pendulum
𝐿
 Formula: 𝑇 = 2𝜋√𝑔
 Data input: length of pendulum
 Output Data: T (Priod of Pendulum)

2. Data Structure

Unit/Magnitude Variable Type of data Description


Length of pendulum l Real/Numeric Input data
Period T Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

T=2*pi*sqrt(l/g)

Stop

4. Coding In MatLab
%Program Computer to Period of pendulum
%Input
l=input ('length of pendulum = ' );
%process
g=10;
T=2*pi*sqrt(l/g);
%output
fprintf( '\nPeriod of pendulum=%8.1f' ,T) ;disp([ ' second']);

5. Testing Program
>> test 1
length of pendulum = 15
Period of pendulum= 7.7 second

>> test 2
length of pendulum = 30
Period of pendulum= 10.9 second

>> test 3
length of pendulum = 40
Period of pendulum= 12.6 second

12. Program to Determine Calor


1. Definition of Problem
 Determine of Calor
 Formula: 𝑄 = 𝑚 ∗ 𝑐 ∗ ∆𝑇
 Data input: mass, heat type substance, temperature change
 Output Data: Q (Calor)

2. Data Structure

Unit/Magnitude Variable Type of data Description


Mass m Real/Numeric Input data
Heat type substance c Real/Numeric Input data
Temperature1 T1 Real/Numeric Input data
Temperature2 T2 Real/Numeric Input data
Calor Q Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

m,c,T1,T2
Q=m*c*(T2-T1)

Stop

4. Coding In MatLab
%Program Computer to Calor
%Input
m=input ('mass = ' );
c=input ('heat type substance = ' );
T1=input ('Temperature1 = ' );
T2=input ('Temperature2 = ' );
%process
Q=m*c*(T2-T1);
%output
fprintf( '\nCalor=%8.1f' ,Q) ;disp([ ' Joule']);

5. Testing Program
>> test 1
mass = 10
heat type substance = 1.6
Temperature1 = 20
Temperature2 = 30
Calor= 160.0 Joule

>> test 2
mass = 32
heat type substance = 1.8
Temperature1 = 40
Temperature2 = 20
Calor= -1152.0 Joule

>> test 3
mass = 10
heat type substance = 2.5
Temperature1 = 30
Temperature2 = 60
Calor= 750.0 Joule

13. Program to Determine Density


1. Definition of Problem
 Determine of Density
𝑚
 Formula: 𝜌 = 𝑣
 Data input: mass, volume
 Output Data: Density

2. Data Structure

Unit/Magnitude Variable Type of data Description


Mass m Real/Numeric Input data
volume v Real/Numeric Input data
Density rho Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

m,v

Rho=m/v

rho

Stop
4. Coding In MatLab
%Program Computer to Rho
%Input
m=input ('mass = ' );
v=input ('volume = ' );
%process
rho=m/v;
%output
fprintf( '\nDensity=%8.1f' ,rho) ;disp([ ' kg/m^3']);

5. Testing Program
>> test 1
mass = 32
volume = 40

Density= 0.8 kg/m^3

>> test 2
mass = 20
volume = 10
Density= 2.0 kg/m^3

>> test 3
mass = 15
volume = 36
Density= 0.4 kg/m^3

14. Program to Determine Gravity force


1. Definition of Problem
 Determine of gravity force
𝑚 𝑚
 Formula: 𝐹 = 𝐺 𝑟1 2 2
 Data input: mass, Gravity, radius
 Output Data: gravity force

2. Data Structure

Unit/Magnitude Variable Type of data Description


Mass 1 M1 Real/Numeric Input data
Mass 2 M2
radius r Real/Numeric Input data
Gravity force F Real/Numeric Output data
3. Algorithm Program
Algorithm Use Flowchart

Start

m1, m2, r

F =G*m1*m2/r.^2

Stop

4. Coding In MatLab
%Program Computer to gravity force
%Input
m1=input ('mass 1 = ' );
m2=input ('mass 2 = ' );
r=input ('radius = ' );
%process
G=6.67*(10^-11)
F=G*m1*m2/r.^2;
%output
fprintf( '\nGravity Force=%8.12f' ,F) ;disp([ ' Newton']);

5. Testing Program
>> test 1
mass 1 = 5
mass 2 = 3
radius = 6
G = 6.6700e-011
Gravity Force=0.000000000028 Newton
>> test 2
mass 1 = 6
mass 2 = 4
radius = 8
G =6.6700e-011
Gravity Force=0.000000000025 Newton

>> test 3
mass 1 = 5
mass 2 = 5
radius = 4
G =6.6700e-011
Gravity Force=0.000000000104 Newton

15. Program to Determine Pressure


1. Definition of Problem
 Determine of Pressure
𝐹
 Formula: 𝑃 = 𝐴
 Data input: force, area
 Output Data: P (pressure)

2. Data Structure

Unit/Magnitude Variable Type of data Description


Force f Real/Numeric Input data
Area a Real/Numeric Input data
Pressure P Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

F,A

P=F/A

P
Stop

4. Coding In MatLab
%Program Computer to pressure
%Input
F=input ('Force = ' );
A=input ('Area = ' );
%process
P=F/A;
%output
fprintf( '\nPressure=%8.1f' ,P) ;disp([ ' Pa']);

5. Testing Program
>> test 1
Force = 10
Area = 5
Pressure= 2.0 Pa

>> test 2
Force = 15
Area = 3
Pressure= 5.0 Pa

>> test 3
Force = 50
Area = 5
Pressure= 10.0 Pa

16. Program to Determine Work


1. Definition of Problem
 Determine of Work
 Formula: 𝑊 = 𝐹𝑠𝑐𝑜𝑠𝜃
 Data input: force, distance, cos(x)
 Output Data: W (Work)

2. Data Structure

Unit/Magnitude Variable Type of data Description


Force f Real/Numeric Input data
Distance d Real/Numeric Input data
Cos(x) x Real/Numeric Input data
Work w Real/Numeric Output data
3. Algorithm Program
Algorithm Use Flowchart

Start

F,d,cos(x)

W=F*d*cos(x)

Stop

4. Coding In MatLab
%Program Computer to Work
%Input
f=input ('force = ' );
d=input ('distance= ' );
x=input ('teta = ' );
%process
x=x*pi/180;
W=f*d*cos(x);
%output
fprintf( '\nWork=%8.1f' ,W) ;disp([ ' Joule']);

5. Testing Program
>> test 1
force = 10
distance= 30
teta = 30
Work= 259.8 Joule

>> test 2
force = 20
distance= 4
teta = 15
Work= 77.3 Joule

>> test 3
force = 30
distance= 30
teta = 60
Work= 450.0 Joule

17. Program to Determine Fluid Velocity


1. Definition of Problem
 Determine of Fluid Velocity
 Formula: 𝑉 = 𝑄/𝐴
 Data input: calor, area
 Output Data: V (Velocity)

2. Data Structure

Unit/Magnitude Variable Type of data Description


Debit Q Real/Numeric Input data
Area A Real/Numeric Input data
Velocity V Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

Q,A

V=Q/A

Stop
4. Coding In MatLab
%Program Computer to Fluid Velocity
%Input
Q=input ('Debit = ' );
A=input ('Area = ' );
%process
V=Q/A;
%output
fprintf( '\nFluid Velocity=%8.1f' ,V) ;disp([ ' m/s^2']);

5. Testing Program
>> test 1
Debit = 30
Area = 2
Fluid Velocity= 15.0 m/s^2

>> test 2
Debit = 40
Area = 4
Fluid Velocity= 10.0 m/s^2

>> test 3
Debit = 50
Area = 10
Fluid Velocity= 5.0 m/s^2

18. Program to Determine Period of Spring


1. Definition of Problem
 Determine of Period of Spring
𝑚
 Formula: 𝑇 = 2𝜋√ 𝑐
 Data input: pi, mass, costanta
 Output Data: T (Priod of Spring)

2. Data Structure

Unit/Magnitude Variable Type of data Description


mass m Real/Numeric Input data
constant c Real/Numeric Input data
Period T Real/Numeric Output data
3. Algorithm Program
Algorithm Use Flowchart

Start

m, c

T=2*pi*sqrt(m/c)

Stop

4. Coding In MatLab
%Program Computer to Period of Spring
%Input
m=input ('mass = ' );
c=input ('constanta = ' );
%process
T=2*pi*sqrt(m/c);
%output
fprintf( '\nPeriod of Spring=%8.1f' ,T) ;disp([ ' second ']);

5. Testing Program
>> test 1
mass = 20
constanta = 15
Period of Spring= 7.3 second

>> test 2
mass = 45
constanta = 15
Period of Spring= 10.9 second

>> test 3
mass = 60
constanta = 15
Period of Spring= 12.6 second

19. Program to Determine Long expension coefficient


1. Definition of Problem
 Determine of Long expension coefficient
 Formula: 𝐿 = 𝐿𝑜 (1 + 𝛼. ∆𝑇)
 Data input: initial length, long expension coefficient, temperature change
 Output Data: L (finish length)

2. Data Structure

Unit/Magnitude Variable Type of data Description


initial length Lo Real/Numeric Input data
Temperature 1 T1 Real/Numeric Input data
Temperature 2 T2 Real/Numeric Input data
Finish length L Real/Numeric Output data

3. Algorithm Program
Algorithm Use Flowchart

Start

lo, t1, t2

lo*(1+(a*(t2-t1)));

Stop

4. Coding In MatLab
%Program Computer to Long expension coefficient
%Input
Lo=input ('initial length = ' );
T1=input ('Temperature 1 = ' );
T2=input ('Temperature 2 = ' );
%process
a=12*(10^-6);
L=Lo*(1+(a*(T2-T1)));
%output
fprintf( '\nLong expension coefficient=%8.8f' ,L) ;disp([ ' meter ']);

5. Testing Program
>> test 1
initial length = 15
Temperature 1 = 30
Temperature 2 = 60
Long expension coefficient=15.00540000 meter

>> test 2
initial length = 30
Temperature 1 = 20
Temperature 2 = 25
Long expension coefficient=30.00180000 meter

>> test 3
initial length = 10
Temperature 1 = 25
Temperature 2 = 30

Long expension coefficient=10.00060000 meter

20. Program to Determine Potential Energy


1. Problem Definition
 Determine potential energy
 Rumus : Ep = m*g*al
 Input data : mass, gravity, altitude
 Output data : potential energy

2. Data Structure

Unit Variable Type of data Keterangan


Mass m Real/Numeric Input data
Gravity g Real/Numeric Input data
Altitude al Real/Numeric Input data
Potential Energy pe Real/Numeric Output data
3. Algorithm Program

Algorithm Use Flowchart

Start

m, g, al

pe = m*g*al

pe

Stop

4. Coding in MatLab
%Computer program to calculate potential energy
%Input
m=input(‘ Mass = ‘);
g=input(‘ Gravity = ‘);
al=input(‘ Altitude = ‘);
%process
pe=m*g*al;
%output
fprintf('\nPotential Energy =%8.3f',pe);disp(' joule');

5. Testing Program
a) Mass = 20
Gravity = 10
Altitude = 3
Potential Energy = 600 joule

b) Mass = 13
Gravity = 10
Altitude = 10
Potential Energy =1300 joule
c) Mass = 62
Gravity = 9.8
Altitude = 50
Potential Energy =30380 joule

Potrebbero piacerti anche