Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Faculty of Engineering
Semester 1 - 2014
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)
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
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:
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
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
Page 3 of 4
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 )
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
Page 4 of 4