logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

The Euler's number (𝑒) is an important mathematical constant that forms the base of the natural logarithms

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Coursework

Question 1 (50 marks)

The Euler's number (𝑒) is an important mathematical constant that forms the base of the natural logarithms. This number can be obtained in MATLAB by typing: exp(1), in other words, 𝑒 to the power of 1. The exact value of 𝑒 can be defined by the infinite series:

where 𝑛! is the factorial of 𝑛.

𝑒 = ∑

𝑛=0

1

𝑛!

You are asked to create a MATLAB M-file named “problem1_XXX.m” (exactly like this, without capital letters or spaces, and substituting XXX by your full student number) that

  1. uses a FOR loop to display in the Command Window the first 10 terms in the sequence. Hint: the factorial of 𝑛 (or 𝑛!) in MATLAB is obtained by typing factorial(n). (20 marks)

  1. calculates the series using the first 10 terms of the (10 marks)

  1. obtains the error of the previous series (in %) with respect to the value of 𝑒 that is stored in the memory of MATLAB. (5 marks)

  1. creates a plot in which the number of terms that are included in the series appears in the abscissa (π‘₯) and the result of the series for the corresponding number of terms appears in the ordinate (𝑦). The line should contain ‘x’ markers to indicate each value of the(10 marks)

  1. includes in the plot useful labels and a line at 𝑦 = 𝑒 to represent the value to which the series should (5 marks)

Question 2 (50 marks)

A person is travelling in a rainy day from London to Cambridge on a direct train without intermediate stops. This person decides to take pictures of one of the windows of the train at intervals of 30 s. The window is a rectangle with a length of 2 m and a height of 1 m. In total, 62 pictures were taken in the 30.5-minutes journey. In each of them the coordinates of the start and the end points (points A and B, respectively) of the rain drops that hit the window were annotated with respect to the system of Cartesian axes represented in Figure 1. This data is included in the files available on Moodle:

XYpoints_timeFromDeparture_XXX.txt

where XXX represents the time from departure in which the picture of the window was taken, in seconds. You should download all these files from the Moodle assignment to your working directory before attempting to complete the exercise. Do not save these files in a different folder, your script should work with the data files stored in the same folder as the script (do not submit the data files, submit only the script, as explained previously). The format in each of these data files is the following:

Column 1: X coordinate of the start point A of the drop in the window, in m. Column 2: Y coordinate of the start point A of the drop in the window, in m. Column 3: X coordinate of the end point B of the drop in the window, in m. Column 4: Y coordinate of the end point B of the drop in the window, in m.

It is known that in a fixed reference the velocity of the rain is π‘ˆπ‘€π‘–π‘›π‘‘ = 10 m/s and that it forms an angle

πœƒπ‘€π‘–π‘›π‘‘ = 300 with respect to the vertical line. Consider that positive angles as counter clock-wise in this exercise. You should also assume that in each time instant the rain drops on the window are only those that appear in the corresponding text file, with the previous ones being completely removed from the window. Also assume that the train movement is completely horizontal in the negative-X direction of Figure 1.

You are asked to create a MATLAB M-file named “problem2_XXX.m” (exactly like this, without capital letters or spaces, and substituting XXX by your full student number) to:

  1. Plot all the rain drops on the window when the time is 0 s (i.e. at the start of the journey) using a FOR loop. The plot should be contained exactly in the perimeter of the window and the rain drops should be represented as solid blue lines that connect the corresponding start and end nodes. Do not represent any additional line(10 marks)

 Define another FOR loop to plot all the rain drops on the window at time equals 180 s (i.e. 3 minutes after departure). The plot should have the same format requirements as the one in

  1. the previous section. Using the same FOR loop created for this section, the absolute velocity of the train with respect to a fixed reference (π‘‰π‘‘π‘Ÿπ‘Žπ‘–π‘›) should be estimated after 180 s from departure. This should be calculated from the arithmetic mean of the angle formed by each rain drop and the vertical line (πœƒ, see Note 3 below). The train velocity should be displayed in the command window in mph.

(20 marks)

  1. Creates another FOR loop to open the 62 data files and to calculate the absolute velocity of the train (π‘‰π‘‘π‘Ÿπ‘Žπ‘–π‘›) during the whole journey. The code should produce a plot in which the time from departure is represented in minutes in the horizontal axis, and the absolute velocity of

the train is included in the vertical axis in mph. Use a black solid line with ‘x’ markers to plot this result.

(10 marks)

 Note 1: When running this file the three plots generated should appear in the screen. Hint: to avoid “losing” the first plot when the next one is generated you should use the command figure(). You are referred to the MATLAB Help for more information about how to use this command.

Note 2: In this problem the first two plots should keep the real proportion between the X and the Y axes to avoid distorting the angles of the rain drops in the figure. In other words, the length of the X axis should appear on the screen as twice the length of the Y axis, as the one shown for example in Figure 1. It can be achieved by using the command: axis equal. You are advice to use the commands xlim() and ylim(), if needed, after including the statement axis equal.

Note 3: The angle formed by a rain drop with respect to the vertical line in the window of a moving vehicle (πœƒ) is given as:

π‘‰π‘‘π‘Ÿπ‘Žπ‘–π‘›   + π‘ˆπ‘€π‘–π‘›π‘‘sin(πœƒπ‘€π‘–π‘›π‘‘)

πœƒ = atan (                                                )

π‘ˆπ‘€π‘–π‘›π‘‘cos(πœƒπ‘€π‘–π‘›π‘‘)

where π‘‰π‘‘π‘Ÿπ‘Žπ‘–π‘› and π‘ˆπ‘€π‘–π‘›π‘‘ are the absolute velocities of the train and of the rain with respect to a fixed reference; πœƒπ‘€π‘–π‘›π‘‘ is the angle of the rain with respect to the vertical line also in a fixed reference framework.

 

Marking criteria

Question 1:

You will get full marks for Section 1 in this question if the FOR loop is fully functional and it does precisely what you are asked to do. 5 marks will be deducted if one term of the sequence is not included or if it includes one extra term that was not requested. 10 marks will be deducted if the sequence is incorrect in two of its terms. No marks will be awarded with 3 or more incorrect terms. 5 marks will be deducted if the terms of the sequence are not displayed in the Command Window when running the code.

You will get full marks for Section 2 if the sum of the series is done correctly and if it is displayed in the Command Window when running the M-file. 5 marks will be deducted if the sum is correct but it is not displayed in the Command Window. No marks will be awarded if the sum is incorrect.

You will get full marks for Section 3 if the error of the previous series is correctly displayed in the Command Window (in %) when running the file. 5 marks will be deducted if the calculation of the error is correct but it is not displayed in the Command Window, or if it is not given as a percentage. No marks will be awarded if the calculation is incorrect.

You will get full marks for Section 4 if the plot is correctly visualised when running the file. 5 marks will be deducted if the result of the series for one of the terms is not included in the plot, or if it includes more than 10 terms. No marks will be awarded if the plot is incorrect in 2 or more of its terms.

You will get full marks for Section 5 if the file includes the necessary commands to label the axes with meaningful text and it includes the horizontal line at 𝑦 = 𝑒. If the text or the horizontal line are not correct or appropriate, 5 marks will be deducted.

In addition, 10 marks will be deducted in Question 1 if the file, as submitted, does not run correctly in MATLAB. Up to 10 marks will be deducted if the comments included to describe succinctly the different parts of the code and its functions are not appropriate, sufficient or if they are unnecessarily long (a comment line should not exceed the vertical line appearing to the right of the Editor view). 5 marks will be deducted if the name of the file is not exactly “question1_XXX.m”, where XXX should be substituted by your full student number. 5 marks will be deducted if the format in the file is poor (e.g. it includes unnecessary spacing between lines or inconsistent tabulations within the loop).

Question 2:

You will get full marks for Section 1 if the plot represents correctly all the rain drops in the window at the time in which the train departs. 5 marks will be deducted if the plot is correct but it is in a style different from the one indicated. 5 marks will be deducted if not all the rain drops are represented in the plot for this time instant. If the axes of the plot do not include labels 3 marks will be deducted. No marks will be deducted if the plot is incorrect.

You will get full marks for Section 2 if the plot represents correctly all the rain drops in the window after 3 minutes from departure and the train velocity is calculated correctly. 5 marks will be deducted if the plot is correct but it is in a style different from the one indicated. 5 marks will be deducted if not all the rain drops are represented in the plot for this time instant. 10 marks will be deducted if the plot is incorrect. If the axes of the plot do not include labels 3 marks will be deducted. 3 marks will be deducted if the velocity of the train is calculated correctly but it is not displayed in the command window as requested. 2 marks will be deducted if the units of the calculated velocity are not in mph as requested. 10 marks will be deducted if the calculation of the train velocity is incorrect.

You will get full marks for Section 3 if the plot represents correctly the velocity of the train in all the instants in which data is provided. 5 marks will be deducted if the plot is correct but it is in a style different from the one indicated. 5 marks will be deducted if the train velocity is not calculated in all the given time instants. Up to 4 marks will be deducted if the units of the calculated velocity and the time are not in mph and in minutes, respectively, as requested. No marks will be deducted if the plot is completely incorrect.

In addition, up to 10 marks will be deducted in Problem 2 if the comments included to describe succinctly the different parts of the code and its functions are not appropriate, sufficient or if they are unnecessarily long: no comment line should exceed the width of the Editor view (marked with a

vertical line). 5 marks will be deducted if the name of the file is not “problem2_XXX.m”, where XXX should be substituted by your full student number. 5 marks will be deducted if the format in the file is poor (e.g. it includes unnecessary spacing between lines or inconsistent tabulations within the loop). 5 marks will be deducted if the three plots do not appear simultaneously on the screen when running the script.

* ’unnecessarily large number of statements’ applies, for example, if you open each of the 62 data files manually in the third section of Question 2.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

994 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

872 Answers

Hire Me
expert
Husnain SaeedComputer science

873 Answers

Hire Me
expert
Atharva PatilComputer science

571 Answers

Hire Me