Professional Documents
Culture Documents
All information required for completing this assignment can be found in ‘MATLAB Workshops’ folder on
Blackboard. It is advisable to complete all tasks in all 3 MATLAB workshops before you start this
assignment’s tasks. For additional reference, any of the following books will be adequate:
Gilat, MATLAB: An Introduction with Applications, John Wiley & Sons; 4th Ed., 2011.
S. Chapman, J., MATLAB Programming for Engineers, Nelson Engineering; 4th Ed., 2007.
H. Moore, MATLAB for Engineers, Pearson Education; 3rd Ed., 2011.
MATLAB TIPS/TRICKS
To get info and examples on how to use a function/command, use doc, e.g. >> doc interp1.
To return to previously typed commands in ‘Command Window’, you can use “arrow up” ↑ key.
Upper or Low Case: MATLAB is case‐sensitive. All functions must be in low cases, but variables can
be in low cases, upper cases or mixed. NO space in function and variable names.
Location to save MATLAB script files or data: You can change work directory (folder) to any other
directory (folder) such as “H:\mywork” (see top left immediately above ‘Command Window’).
MARKING CRITERIA
Your submission will be marked according to the following marking criteria:
[80‐100]: In addition to [70‐79], additional marks will be awarded to the quality of MATLAB
programs and explanations, for example, efficient program codes, proper in‐program
explanations/comments.
[70‐79]: All MATLAB programs are correct and correct results are produced. Program codes are
presented with proper annotations to explain the functions of the programs.
[60‐69]: The MATLAB programs related to majority of tasks are correct and correct results are
produced for majority of tasks. Program codes are presented with some explanations and
comments.
[50‐59]: The MATLAB programs related to over half of tasks are correct and correct results are
produced for over half of tasks.
[40‐49]: The MATLAB programs related to 1/3 of tasks are correct and correct results are produced
for over 1/3 of tasks.
[30‐39]: The programs fail to execute; however, some good efforts have been made to complete all
tasks. Some program codes are presented.
[0‐29]: Suitable marks will be given based on the programs produced and the effort made.
The final mark will be calculated according to the following weighting factors:
P1 P2 P3 P4 Discretionary Mark
(programs correctness and efficiency)
20% 25% 35% 10% 10%
Page 2 of 7
CE2602-CE2603 Sustainable Construction/Infrastructure and Professional Skills
For the truss shown in the figure below, unknown forces in the members are determined
by solving the following linear equations simultaneously:
The applied forces are F1=32(1+0.3S) N and F2=23(1+0.2S) N. The inner angles, θ1 and
θ2 are 45° and 30°, respectively.
Use suitable MATLAB commands to solve for unknown forces RAx, RAy, RCy, FAD, FAB,
FBD, FCD, and FBC.
Note that the parameter S in F1 and F2 is a parameter related to each student’s ID and must
be generated before you start to solve this problem using the following MATLAB codes:
RandStream.setGlobalStream(RandStream('mt19937ar','seed',1234567));
S=rand(1);
Replace this with your student ID
HINTS:
To solve system of equations, see MATLAB Tutorial (in ‘MATLAB Workshops’ folder on
Blackboard) page 13.
If you want to present final answers with formatted texts, use fprintf command.
Find more information in MATLAB Tutorial (in ‘MATLAB Workshops’ folder on Blackboard)
page 36.
Page 3 of 7
CE2602-CE2603 Sustainable Construction/Infrastructure and Professional Skills
2
f (a, h) 11.25ah 7h 3
1300
440
ah
1546 2 (a2 h)
100
ah 0.26
a 15 0
a 1 0
h 0.3 0
h 0.1 0
HINTS:
Use fmincon command, see MATLAB Tutorial (in ‘MATLAB Workshops’ folder on Blackboard)
page 28.
The objective function is a function of two variables. To solve this type of question, the objective
function must be first converted into a function of a single vector variable. The same should be
done for constraint functions.
Basically, you need to define TWO functions, one function for the objective, another for
describing constraints. See examples for constraint optimisation in MATLAB Tutorial (in ‘MATLAB
Workshops’ folder on Blackboard) pages 28‐30.
You need to do some preparation work to convert all constraints to the standard format so that
they can be described by the constraint function.
Page 4 of 7
CE2602-CE2603 Sustainable Construction/Infrastructure and Professional Skills
A ball is thrown into the air with the initial velocity v0 and the angle α to horizontal
direction (see figure below).
The air is assumed to have friction which is proportional to the velocity. The horizontal
and vertical velocities and positions can be determined by solving the following
differential equations (derived from the Newton’s law):
dvx B
dt m v x
vx (0) v0 cos ()
dvy B
g v
dt m y vy (0) v0 sin ()
dx v x x(0) 0
dt y(0) 0
dy v y
dt
P3.1 Use a differential equation solver in MATLAB (i.e. ode45, ode23 or ode15s) to solve
the above equations to find the solution for vx, vy, x, y and the corresponding time history
t for the time period of [0, 5] seconds. Plot all four graphs (vx versus t, vy versus t, x versus
t, and y versus t) in one figure window.
P3.2 Find the time (tf) when the ball strikes the ground, i.e. y=0. The way to find the time tf is
to solve the system differential equations for a longer period time (done in P3.1) and then
use interp1 to find tf when y(tf)=0.
P3.3 For the time interval [0, tf], repeat the ODE solution of P3.1 to calculate the complete time
history of t, vx, vy, x and y. Plot all four graphs (vx versus t, vy versus t, x versus t, and y
versus t) in one figure window.
Page 5 of 7
CE2602-CE2603 Sustainable Construction/Infrastructure and Professional Skills
P3.4 When the initial velocity changes, the time that the ball hits the ground will change. For
the following 10 different initial velocities and angles (k=1, 2, 3,…,10), determine the time
that the ball hits the ground:
Note that S is the student related parameter generated in the same way as in P1.
HINTS:
For P3.1:
To solve multiple 1st order differential equations, see problem W2P4 in Workshop 2 and
MATLAB Tutorial (in ‘MATLAB Workshops’ folder on Blackboard) page 32.
The first step is to define a MATLAB function (anonymous function or function m‐file) to describe
the ball throw dynamic equations with ‘dotz’ as the function output, t (time) and z as the input.
Note that the only task for this function is to describe four differential equations in a vector
format, nothing else should be put into this function!
To plot all four graphs in one figure window, use subplot command. See problem W1P4 in
Workshop 1 and MATLAB Tutorial (in ‘MATLAB Workshops’ folder on Blackboard) page 19.
For P3.2:
This can be done by the interp1 and/or find command(s) (MATLAB Tutorial (in ‘MATLAB
Workshops’ folder on Blackboard) pages 47‐48). From
the graph on the right, it can be seen that no data point
at exactly y(t)=0, so that some approximations must be
made. We can find the first data point when y(t)<0 and
the last data point when y(t)>0 and then approximately
determine tf.
Method 1: Approximate with more data points
Pindex=find(y<0);
yselect=y(Pindex(1)-3:Pindex(1)+3);
tselect=t(Pindex(1)-3:Pindex(1)+3);
tf=interp1(yselect, tselect,0);
Method 2: Very rough approximation
Pindex=find(y<0);
tf=(t(Pindex(1))+t(Pindex(1)-1))/2;
For P3.4: You need to use loop for this task, see problem W3P3 in Workshop 3.
Page 6 of 7
CE2602-CE2603 Sustainable Construction/Infrastructure and Professional Skills
Write a MATLAB program to call all programs written for the first three problems in this
assignment. When this program is executed, a selection menu similar to the following one
should be presented:
---------------------------
Select Problem to solve:
---------------------------
1: Problem 1
2: Problem 2
3: Problem 3
Once the selection is made, the relevant program should be executed to solve the problem
selected. The program should be able to return to the selection menu before all problems
have been solved.
HINT:
Use MATLAB command switch-case-end, see problem W3P4 in Workshop 3.
Page 7 of 7