Assignment title: Information


CE2602/CE2603 Sustainable Construction/Infrastructure and Professional Skills Assignment for MATLAB Programming Page 1 of 7 Submission Deadline: 4pm on Monday 13th March 2017 What to Submit: The report together with all MATLAB programs on a CD All information required for completing this assignment can be found in Lecture Notes (Blackboard). It is advisable to complete all tasks in all 3 MATLAB workshops before you start the assignment 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 program or data: You can change work directory (folder) to any other directory (folder) such as "H:\mywork" (see top left immediately above command window).  To copy a figure into a word document use "copy figure" under "Edit". You can change figure copy options and figure properties under "Edit". REQUIREMENT FOR PROGRAMS  All tasks in each problem should be solved by ONE script file together with function files if required.  All MATLAB commands should be entered into script files, NO command should be entered in command window >> unless it is for testing purpose.  Use ; to suppress all intermittent results from MATLAB command window. However, all final results should be presented on the Command Window very clearly using formatted texts (fprintf( )).  All plots should have titles and labels for all axes.  To make a MATLAB program readable for other program users and yourself, it is important to include some comments and very brief explanation throughout the program. In MATLAB % is used to add comments. On any line of program, anything after % will be ignored when the program is executed. The first contiguous comment on the program becomes the script's help file. It is a good idea to identify main and important variables used in the beginning of program. Please add sufficient comments when you write the program, this will help you to avoid wasting time later when you need to debug the program. However, it is not necessary to comment every line of program. Only comment on important lines.  The program should only require the minimum intervention by users. If the user is required to enter any information (e.g. enter some numbers), some clear and self‐explanatory prompts should be presented on the Command Window. REQUIREMENTS FOR REPORT  Check "Sample Assignment Report" about report format required.  It is desirable to include some very brief explanations for the program development, for example, to derive mathematical equations which are used in the program, to use a flow chart to explain the program flow etc.  All final results and plots for each task should be presented in the report. When appropriate, some discussions on results should be included.CE2602/CE2603 Sustainable Construction/Infrastructure and Professional Skills Assignment for MATLAB Programming Page 2 of 7  All programs (MATLAB codes) should be included in the report with some annotations which explain the function of a line of code (if it is important) or a block of codes. Do not explain every code line, only explain according to tasks or sub‐tasks.  Maximum page number for the report is 12. REQUIREMENTS FOR SUBMITTING PROGRAMS ON CD  All programs and generated data files should be provided on a CD which is submitted with the report. Before you burn files to the CD, it is advisable to create a folder on the computer and put all files in this folder and test run them within MATLAB.  For the report marking, all programs (script files) will be tested to check their correctness. MARKING CRITERIA All problems will be marked according to the following marking criteria. [80‐100]: In addition to [70‐79], additional marks will be awarded to quality of MATLAB program and explanations, for example, efficient program codes, proper in‐program explanations/comments. [70‐79]: The MATLAB programs are correct and correct results are produced. Program codes are presented in the report with proper annotations to explain the functions of the program. Results are presented clearly on the report and the results are discussed (if required). [60‐69]: The MATLAB programs related to majority of tasks are correct and correct results are produced for majority tasks. Program codes are presented in the report with some explanations and comments. Results are presented clearly on the report and the results are discussed (if required). [50‐59]: The MATLAB programs related to over half of tasks are correct and correct results are produced for over half of tasks. Program codes are presented in the report clearly. Produced results are presented on the report and some discussions are presented (if required). [40‐49]: The MATLAB programs related to 1/3 of tasks are correct and correct results are produced for over 1/3 of tasks. Program codes and some results are presented in the report. [30‐39]: The programs fail to run; however, some good efforts have been made to complete all tasks. Some program codes are presented in the report. [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 (report presentation, program correctness and efficiency) 25% 30% 30% 5% 10%CE2602/CE2603 Sustainable Construction/Infrastructure and Professional Skills Assignment for MATLAB Programming Page 3 of 7 P1. Use MATLAB to solve linear simultaneous equations For the truss shown in the figure below, unknown forces in the members are determined by solving the following linear equations simultaneously: R F Ax AB + = cos 0 θ + 1 FAD − = FBC cos 0 θ − 2 FCD R F Ay AB + = sin 0 θ1 R F Cy BC + = sin 0 θ2 F F F BC cos cos θ − θ − 2 AB 1 1 = 0 F F CD AD − = 0 − − θ − θ F F F BD BC sin sin 2 1 AB = 0 FBD − F2 = 0 The applied forces are F1=45(1+0.3S) N and F2=32(1+0.2S) N. The inner angles, θ1 and θ2 are 45° and 30°, respectively. P1.1 Convert this set of linear equations into matrix format (hand solution). P1.2 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',1526584)); S=rand(1); P1.3 Present the final results on Command Window using formatted text. What to present on the report? What to submit on CD? Hand solution of P1.1 MATLAB script of P1.2 Results of P1.3 (screen capture) Single MATLAB script file (program) Replace this with your student idCE2602/CE2603 Sustainable Construction/Infrastructure and Professional Skills Assignment for MATLAB Programming Page 4 of 7 P2. Use MATLAB to solve optimisation problems in engineering design Consider the two-bar truss shown in the figure below. The objective is to minimise the volume V of the two bars AC and BC. The cross-sectional areas of the bars AC and BC are denoted as S1 and S2, respectively, and the vertical position of joint is denoted as h. The constraints of the system are that the tensile stresses on the two bars must be less than or equal to σ=105 (1+0.1S) kPa and that the vertical position remains between 1m and 3m. (HINT: use fmincon command.) The volume V of the two bars is given by: 2 2 V S h S h = + + + 1 2 16 1 Subject to the following constraints: ( ) ( ) 1 2 2 1 2 2 1 0. 1 3, 0, 0 20 16 80 1 1 1 0.1 h S S h hS h hS S S   ≤ ≤ > >   +  ≤ σ   + ≤ σ   + + where S is the student related parameter generated in the same way as P1. What to present on the report? What to submit on CD?  Any preparation work to convert the problem functions to standard format so that can be described in MATLAB.  Final results (h, S1 and S2 which minimises V and the minimal value for V).  All MATLAB scripts (including function files if there are any).  Main MATLAB script file (program).  Two MATLAB function files if functions are defined as function files not anonymous functions.CE2602/CE2603 Sustainable Construction/Infrastructure and Professional Skills Assignment for MATLAB Programming Page 5 of 7 P3. Use MATLAB to solve complex engineering problems (differential equation solutions, data interpretation, loop, 2-D plots and subplots) 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): x x y y x y dv B v dt m dv B g v dt m dx v dt dy v dt   = −   = − −   =  =  0 0 (0) cos (0) sin (0) 0 (0) 0 x y v v v v = x y  α   = α   =   = with m B g = = = α = + 10, 2, 9.81, 35 (1 0.2 ), 28(1 0.2 ) ° S v S 0 = + where S is the student related parameter generated in the same way as P1. 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 corresponding time history t for the time period of [0, 6] seconds. Use subplot command to plot four graphs (vx versus t, vy versus t, x versus t, y versus t) in the same figure window. (Do not present all data of vx, vy, x and y on Command Window screen and the report. Only graphs need to be presented in the report.) 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. (HINT: use find command and/or interpretation.)CE2602/CE2603 Sustainable Construction/Infrastructure and Professional Skills Assignment for MATLAB Programming Page 6 of 7 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. Use subplot command to plot four graphs (vx versus t, vy versus t, x versus t, y versus t) in the same figure window. P3.4 When the initial velocity changes, the time when the ball hits ground will change. For the following 10 different initial velocities and angles (k=1, 2, 3,…,10), determine the times when the ball hits the ground: 0 0 ( ) 28(1 0.2 )[1 0.05( 1)] ( ) 35 (1 0.2 )[1 0.01( 1)] v k S k k S k ° = + − − α = + − − The times should be stored in a vector and then plot it against initial horizontal velocities. What to present on the report? What to submit on CD?  P3.1, P3.3, P3.4: Plots generated.  P3.2: The time when the ball hits the ground.  All MATLAB scripts (including  function files if there are any).  Main MATLAB script file (program).  MATLAB function files if functions are defined as function files not anonymous functions.CE2602/CE2603 Sustainable Construction/Infrastructure and Professional Skills Assignment for MATLAB Programming Page 7 of 7 P4. MATLAB program branches Write a MATLAB program to call the programs written for the first two problems in this assignment. When this program is run, a selection menu similar to the following one should be presented: --------------------------- Select Problem to solve: --------------------------- 1: Problem 1 2: Problem 2 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. What to present on the report? What to submit on CD? All MATLAB scripts MATLAB script file (program)