(5/5)

You are required to submit two M-files that respond to the brief below. These files should be ready to be run in MATLAB to answer the questions formulated in the brief.You should not submit the numerical answers or the plots. Do not include any additional material apart from the two M-files because it will not be considered. However, you should include succinct comments within the M-files to explain the different parts and built-in functions that you are using, always respecting the rules for commenting in MATLAB (read carefully the marking criteria below). Only Moodle submissions will be considered.

This work should be entirely your own. Any potential case of plagiarism will be investigated based on the comments that you need to include in the M-files to describe them using your own words. If plagiarism is found it will be considered a serious academic misconduct and you will be invited to defend the originality of your work in a formal interview.

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)

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

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

4. 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 series.

(10 marks)

5. includes in the plot useful labels and a line at 𝑦 = 𝑒 to represent the value to which the series should converge. (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:

RainDrops_timeFromDeparture_YYY.txt

where YYY 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.

Figure 1. Reference system of coordinates in the window of the train.

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 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 in the figure.

(10 marks)

2. Define another FOR loop to plot all the rain drops on the window at time equals 600 s (i.e. 10

minutes after departure). The plot should have the same format requirements as the one in

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 600 s from

departure. This should be calculated from the angle of each rain drop with respect to the vertical line

( , see Note 3 below), and then the arithmetic mean and the standard deviation of train speed should be obtained from the values of the speed obtained for all the rain drops. The mean speed of the train and its standard deviation should be displayed in the command window.

(20 marks)

3. 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:

(5/5)

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

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. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

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

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

Get Free Quote!

438 Experts Online