Vous êtes sur la page 1sur 4

ENG1060 Computing for Engineers

Faculty of Engineering
Semester 1 - 2014

ENG1060 Computing for Engineers


Laboratory 1
This laboratory comprises 2% of your final grade. You will be assessed
during your laboratory session by the demonstrators. You will be assessed
on the quality of your programming style as well as the results produced by
your programs. Save your work in M-Files called lab1t1.m, lab2t2.m etc
(Demonstrators will show you how to work in M-files at the start of
the lab)
The questions are designed to test your recollection of the lecture material
in week 1. This laboratory will introduce you to MATLAB and cover using
MATLAB as a calculator and writing simple programs in M-files.
Note: Some of the functions presented would be new to you and you
should use the MATLAB HELP to learn how to use them.

Task 1 1 mark
Write an M-file to complete the following.
Use the following values for the variables x and y; x = 10, y = 3.

1. u = x + y
2. v =

xy
4

y
3. w = x sin
2
4. n = mod( x, y )
5. z = linspace( y, x,15)

(What does the command mod do?)


(What does the command linspace do?)

NOTE : Typing help elfun into the command window will provide you a listing of
the elementary mathematical functions available.
MATLAB Introduction Laboratory

Page 1 of 4

ENG1060 Computing for Engineers

Task 2 1 mark
The standard distance of a marathon is 26 miles and 385 yards. Write an M-file
that converts the marathon distance into kilometers.
Note: 1 km = 0.62137 miles, and 1 mile = 1760 yards

Task 3 1 mark
The absolute pressure at the bottom of a liquid store tank that is vented to the
atmosphere is given by:

Pabs , bottom = gh + Poutside


where
Pabs,bottom = the absolute pressure at the bottom of the store tank (Pa)
= liquid density (kg/m3)
g = acceleration due to gravity (m/s2)
h = height of the liquid (m)
Write an M-file that calculates Pabs,bottom (in Pascals) if = 1000kg/m3, g = 32.2
ft/s2, h = 7 yards and Poutside = 1 atm.
Note: 1 foot = 0.3048 metres ; 1 yard = 0.9144 metres ; 1 atm = 101325 Pa

Task 4 1 mark
The equivalent resistance Req of four resistors R1, R2, R3 and R4 connected in
series is given as
Req = R1 + R2 + R3 + R4
The equivalent resistance Req of four resistors R1, R2, R3 and R4 connected in
parallel is given as
1
Req =
1
1
1
1
+
+ +
R1 R2 R3 R4
Write an M-file to calculate the equivalent resistance of four resistors (270, 1k,
890 and 740) if they are connected
(a) In series?
(b) In parallel?
MATLAB Introduction Laboratory

Page 2 of 4

ENG1060 Computing for Engineers

Task 5 1 mark
If a stationary ball is released at a height h above the surface of the Earth, the
velocity of the ball v when it hits the earth is given by the equation:
v = 2 gh
where
g is the acceleration due to gravity
h is the height above the surface of the Earth (assuming no air friction).
Write an M-file that calculates the velocity of a stationary ball when it hits the
earth, if it is released at 5m above ground. (Use g = 9.81 ms-2)

Task 6 1 mark
The potential energy of an object due to its height above the surface of the Earth
is given by the equation
PE = mgh
where
m is the mass of the object
g is the acceleration due to gravity (g = 9.81ms-2)
h is the height above the surface of the Earth.
The kinetic energy of a moving object is given by the equation
1
KE = mv 2
2
where
m is the mass of the object
v is the velocity of the object.
Consider a 5kg cat falling from the roof. Write an M-file that calculates the total
energy (potential energy plus kinetic energy) possessed by this cat in the earths
gravitational field when it is experiencing velocity of 1.5 ms-1 at 300mm above
ground.
Hint: Be careful with units

MATLAB Introduction Laboratory

Page 3 of 4

ENG1060 Computing for Engineers

Task 7 2 marks
Radioactive decay is modeled with the exponential function:

f (t ) = Ae kt
where
t is time
A is the amount of material at t=0
k is a constant
Gallium-67, which has a half-life of 3.261 days, is used for tracing cancer. If 100
mg are present at t=0, write an M-file that determines the amount that is left after
7 days.
Hint: You need to determine the constant k first (rearrange equation) and then
calculate f(7) using original equation

Task 8 1 mark
The distance between two points (x1, y1) and (x2, y2) on a Cartesian coordinate
plane is given by the equation d =

( x1 x2 ) + ( y1 y2 )

. Write an M-file that

calculates the distance between the points (2,3) and (8,-5).

Task 9 1 mark
A diver looking for an old shipwreck jumps of his boat and swims 60m east and
25m south on the water surface and then dives 30m below the water surface to
reach his target. Write an M-file that calculates the minimum distance the diver
would cover if he swam towards the target in a straight line?
Hint: Apply Pythagoras theorem

MATLAB Introduction Laboratory

Page 4 of 4

Vous aimerez peut-être aussi