CPT3701_Tutorial 3
Question 1
1.1. In the metric system, fluid flow is measured in cubic meters per second (m3/s). A cubic
foot per second (ft3/s) is equivalent to 0.028 m3/s. Write a m.file titled flowrate that
will prompt the user for flow in m3/s and will print the equivalent flow rate in ft3/s.
Hint this should be the output:
>> flowrate
Enter the flow in m^3/s :15.2
A flow rate of 15.200 meters per sec
is equivalent to 542.857 feet per sec
(10)
1.2. Create row of vectors starting with 2, decreasing in increment of -1 to -9
(2)
1.3. Create a random matrix (4x4)
(1)
1.3.1. Fill the second row with 2 4 6 7.
(1)
1.3.2. Fill the first column with 3s.
(1)
1.3.3. Fill the third row with ones.
(1)
1.2. Working on the workspace plot exp(-x) for values of −1 ≤ 𝑥 ≤ 3 in steps of 0.2. Label
the x-axes, y-axes and title of the graph as x, y and Exp(-x).
(10)
[26 marks]
CPT3701_Tutorial 3
Question 2
2.1. Using OCTAVE solve 𝑥1 , 𝑥2 𝑎𝑛𝑑 𝑥3 for the following equations:
−2𝑥1 + 𝑥3 = −4
−3𝑥1 + 4𝑥2 − 2𝑥3 = 3
𝑥1 − 7𝑥2 − 5𝑥3 = 6
(10)
2.2. Figure 1 shows three reactors connected by pipes the volumetric flow rate is tabulated
in table 1:
Figure 1. Three reactors linked by pipes
Table 1
Volumetric flow rate 𝒎𝟑⁄
𝒔
Q1 500
Q3 180
Q33 100
Q13 45
Q12 90
Q23 70
Q21 30
2.2.1. Develop the mass balance for each reactor.
(6)
2.2.2. Using OCTAVE find the following concentrations 𝑐1 , 𝑐2 , 𝑎𝑛𝑑 𝑐3 .
(8)
CPT3701_Tutorial 3
[24 marks]
Question 3
3.1. Create two column vectors T=[5:5:25]’ and S=[27:2:33]’. Then, by only using the name of the
vectors (T and S), create a column vector R that is made from the elements of T followed by
the elements of S.
(4)
3.2. Define the variables 𝑥 = 3.4 and 𝑦 = 5.8, and then use them to create a row vector (assign
it to a variable named e) that has the following elements: 𝑥⁄𝑦, 𝑥 + 𝑦, 𝑥 𝑦 , 𝑥 × 𝑦, 𝑦 2 and 𝑥.
(4)
3.3. Create a variable g that is a row vector in which the first element is 3 and the last element is
27, with an increment of 4 between the elements (3, 7, 11, … , 27).
(4)
3.4. Create the following matrix by typing one command. Do not type individual elements
explicitly
D=
1 1 1 1
1 1 1 1
1 1 1 1
8 6 4 2
(4)
3.5. Create the following matrix by typing one command. Do not type individual elements
explicitly
G=
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
0 0 0 1 1
0 0 0 1 1
0 0 0 1 1 (4)
3.6. Create the following three row vectors: a=[5 8 -1 0 2], b=[4 1 9 -2 3], and c=[-3 5 0 6 1].
CPT3701_Tutorial 3
3.7. Use the three vectors in a OCTAVE command to create a nine-element row vector consisting
from the first three elements of the vectors a, b, and c, respectively (i.e., 5 8 -1 4 1 9 -3 5 0).
(6)
3.8. (Use the three vectors in a OCTAVE command to create a nine-element column vector
consisting from the last three elements of the vectors a, b, and c, respectively
(4)
[30 MARKS]
Question 4
A thin nanosurface that has a single point exposed to an external source of heat at 600 ℃ together
with edges that are cooled to 5 ℃. After a while, the temperature will become constant throughout
the surface. Of course, the closer a point is to the source of heat, the hotter it will be, and the closer
a point is to an edge, the cooler it will be. For a steady state, you expect that the temperature at any
point to be the average of the temperatures around it. Using the an approximation, you get the
following results:
Figure 2. A grid of thin nanosurface
Where,
5 + 𝑡2 + 𝑡5 + 5
𝑡1 =
4
5 + 𝑡3 + 𝑡6 + 𝑡1
𝑡2 =
4
CPT3701_Tutorial 3
𝑡4 + 605 + 𝑡2
𝑡3 =
4
10 + 2𝑡3
𝑡4 =
4
𝑡1 + 𝑡6 + 𝑡7 + 5
𝑡5 =
4
𝑡2 + 600 + 𝑡8 + 𝑡5
𝑡6 =
4
𝑡5 + 𝑡8 + 𝑡9 + 5
𝑡7 =
4
2𝑡6 + 2𝑡7
𝑡8 =
4
2𝑡7 + 10
𝑡9 =
4
4.1. Find the linear equation. Use OCTAVE to find 𝑡1 , 𝑡2 , 𝑡3 , 𝑡4 , 𝑡5 , 𝑡6 , 𝑡7 , 𝑡8 , 𝑎𝑛𝑑 𝑡9
[15 marks]
CPT3701_Tutorial 3