Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
EG-127/127J SUPPLEMNTARY – MATLAB Coding Assignment
EG-127/EG-127J – SUPPLEMENTARY COURSEWORK
MATLAB Coding Assignment (100%) 2020/21
Turnitin Submission Deadline: 10am Friday 6th August 2021
Basic details
For this INDIVIDUAL assignment, you are asked to submit BOTH your (i) MATLAB coding (in a SINGLE
‘.m’ file) and (ii) the same coding but with outputs to the problem questions specified in this question
sheet in a PDF DOCUMENT (PLEASE DO NOT USE PUBLISH IN MATLAB).
The PDF should contain:
1. A cover page giving your name and student number and including the signed statement "I
confirm that I have not received help from, or given help to, anyone else in constructing the
solution to this individual assignment, and I certify that this is all my own work ". (See Cover
Page Template, after Questions).
2. A complete documented listing of your actual MATLAB files (Print to PDF. i.e. NOT retyped by
you and NO screenshots of code.).
3. A listing of the actual command window outputs from MATLAB giving the answers requested
(i.e. NOT retyped by you and NO screenshots of code) & images of your figures.
4. Appropriate referencing to any publication or web-based material that you have used to help in
the learning of MATLAB to construct your solution.
The report should be saved as a single PDF document and submitted through the Turnitin submission
link via Canvas. Your name and student number must be clearly visible. In addition to your report, you
must submit your WORKING MATLAB file to the Canvas submission link to verify functionality of the
code (there should be only a single .m file (containing the inputs and calculations for each question,
with the sub-functions requested).
Marking
Overall, for this piece of coursework, which is worth 100% of the module, marks will be awarded as
stated in the rubric at the end of this document. In the rubric, the possible marks are stated for each
question.
IMPORTANT –
? A MAXIMUM page limit is 12 Pages for the entire PDF submission. Any pages after this limit will
NOT be marked!
QUALTY MARKS WILL BE LOST IF:
? Amendments to the submitted code need to be done to make it run. (ALL quality marks lost)
? The PDF submission document containing the code, command window outputs and graphs is not
submitted to the Turnitin link, and so needs to be marked offline. (ALL quality marks lost)
? There are no results or figures in the PDF (ALL quality marks lost)
? The MATLAB submission consists of multiple .m files (3/5 quality marks lost)
Submission details
Coursework submissions must be submitted to Canvas BEFORE 10am on Friday 6th August 2021
Work that is submitted late (AFTER 10am 6th August 2021) will be awarded ZERO marks.
Late submission due to certificated illness will be dealt with according to standard procedures.
EG-127/127J SUPPLEMNTARY – MATLAB Coding Assignment 2020/21
Question 01: Conditional Statements, Fprintf and random numbers
? In this question, you are firstly to create a vector for x and y, where x has a range from 0
to 16 in separations which will create a smooth curve for the function y = sin(x)3 (in rads).
? A randomly generated value of sin(x)3 within the x range is to be created and plotted onto
a figure, also containing the full x, y curve, to show that the randomly generated value
coincides with the line.
? This figure must be fully annotated (labels, title, grid and legend), and when run again,
the randomized value must automatically change.
? Conditional statements are then to be used to generate displaying statements in the
command window to state that the random sin(x)3 value generated is either positive or
negative, and has further statements stating whether the value is higher than 0.6,
between 0.3 and 0.6, between 0 and -0.3, between -0.3 and -0.6, lower than -0.6 or equal
to zero. The randomized value must be displayed in the printing statements, and update
automatically if run again.
(20 Marks Total)
EG-127/127J SUPPLEMNTARY – MATLAB Coding Assignment 2020/21
Question 02: Moment & Force Vector Resolving, using inputs and a sub-function
Figure 1a: Force Vector Diagram: Part 1 Figure 1b: Force Vector Diagram: Part 2
Using the force vector diagrams in Figure 1a and 1b (for parts 1 and 2 respectively), calculate
the Forces of FCA, FDB and FCE. The values of the force Fm, and the angles and are stated in
Table 1. The calculations themselves are to be performed in a sub-function, into which the
initial conditions are to be sent.
This question is split into 2 parts, and you will need to run the same sub-function twice,
separately for the values in each part. In part 1, the inputs to be used are those from the
original EG-166 (Engineering Mechanics) Worksheet 3, Question 2, and for part 2, new
values are to be used. The Fm, and input values for parts 1 & 2 are given in Table 1 and
should be sent as inputs to the same sub-function (once for part 1, and then again for part
2).
The initial condition values in Table 1, and sub-function calculations are to be printed in the
MATLAB Command Window; and the MATLAB code is to be part of the single MATLAB
assignment ‘.m’ file.
Part 1: Calculate FCA, FDB and FCE, using EG-166 Worksheet values.
Part 2: Calculate FCA, FDB and FCE, using new initial conditions.
Table 1: Initial Condition Force and Angle inputs for Parts 1 and 2.
(20 Marks Total)
Fm -500 N Fm -281 N
30 Degrees 20 Degrees
45 Degrees 58 Degrees
DistA 5 m DistA 3.72 m
DistB 5 m DistB 6.28 m
Part (1) Part (2)
α
β
α
β
EG-127/127J SUPPLEMNTARY – MATLAB Coding Assignment 2020/21
Question 03: Image reading, showing, greyscale and extraction using array indexing
Figure 2: College of Engineering logo image Figure 3: Extracted Greyscale Crest
An essential part of coding is finding out how to perform a task using tools that you do not
already know.
(a) By using the help files of MATLAB, read in and display the Figure 2 image of the coloured
version of the College of Engineering logo as a greyscale version with a suitable title in a figure
window. To bring the image into MATLAB and present it into the window, you should use the
commands imread() and imshow(), but you need to find the appropriate method of converting
to greyscale yourself.
(b) A greyscale image in MATLAB is represented as numerical values in an array, representing
the saturation level of each pixel of the image. The row number or column number of pixels
are simply the array rows or columns for the stored matrix in the MATLAB workspace.
Use array indexing to extract from the greyscale image of part (a), the crest of the logo, and
show the extracted image as shown in Figure 3, but with a suitable title on the image.
The jpeg image file to use in the question is located on the assignment page on Canvas as
‘EG127_127J_Q3_Supp_Image_20_21.jpg’.
(20 Marks Total)
EG-127/127J SUPPLEMNTARY – MATLAB Coding Assignment 2020/21
Question 04: Vehicle Speed Calculation using for Loop and Plotting script
The displacement (m) created from a shock applied to a damped component can be
recreated using Equation 4 (using degrees (not radians) in this case).
_() = 1.4 sin(1.6) + 0.3tan?(1.3) Eqn. 4
Using time in seconds (s) ranging from 30s to 34.58s the displacement of this shock applied,
is to be recreated in micrometers ().
(a) In your single MATLAB assignment ‘.m’ file, using a ‘for’ loop, and a loop counter for
indexing, generate a variable containing the displacement calculations for equation 4.
In a 2x1 sub-plot figure, use the displacement and time variables to plot the vibration
() versus the defined time(s) range, with x and y axis labels, grid and title in the
top sub-plot window.
(b) In the bottom sub-plot window, the same vibration vs time data is to be plotted but,
any values that are greater than 20, are to be represented as a green line, and any
lower than 20 are to be a red line. Additionally, two dashed horizontal lines are to be
plotted, showing the limits at which the colour styles change. A legend will be
required on the 2nd sub-plot window and must be fully annotated. The y axis for the
bottom sub-plot is to be limited to between -100? to 100?.