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

Introduction to MATLAB

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Introduction to MATLAB

 This is an individual coursework that is to be submitted in Moodle before 16/04/2020 at 23:59. 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. calculatesthe 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:

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.

 

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

(10 marks)

 

 

 

 

 

2. 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

 

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)

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.

 

 

(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

799 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

569 Answers

Hire Me
expert
Husnain SaeedComputer science

750 Answers

Hire Me
expert
Atharva PatilComputer science

633 Answers

Hire Me

Get Free Quote!

325 Experts Online