Assignment - eng 2314 eng60104 - write a matlab script


- All work is to be submitted as a SINGLE pdf document report. Your document should contain all the MATLAB script (including comments), the solutions generate by MATLAB, and graphs that you were asked to produce. You MUST use print screen method to show the MATLAB solution.

- Your code must be clear and simplify

- Use the template provided

- Each M-file must start include your name, student ID, and Question No.

- For the analytical, you may write your solution in A4 paper and scan it. Then, insert as picture into word document. OR you may type your solution in the word document.

- Name your file: yourname - Assign 2

- All your work must be presented in neat and tidy manner.

- Marks will be given according to the quality of documentation.

- You MUST submit your assignment electronically through moodle under Assignment 2 section.

- Late submission will be penalized (10% per day).

- Answer all the questions

- Good luck

Section A

Question 1

Write a MATLAB script that calculates the cost of shipping a package according to the following price schedule.

Type of service

Weight

0 - 0.5 lb

0.5 - 5 lb

More than 5 lb

Ground

(5 - 7 Days)

 

$0.70 + $0.06/oz

$1.18 + $0.42 for every additional

0.5 lb (or fraction)

$4.96 + $0.72 for every additional 0.5 lb (or fraction)

Express

(3 - 4 Days)

 

$2.40 + $0.25/oz

$4.40 + $1.20 for every additional

0.5 lb (or fraction)

$15.20 + $1.80 for every additional 0.5 lb (or fraction)

Overnight (One Day)

 

$12.20 + $0.80/oz

$18.60 + $4.80 for every additional

0.5 lb (or fraction)

$61.80 + $6.40 for every additional 0.5 lb (or fraction)

The program asks the user to enter the type of service (Ground, Express, or Overnight) and the weight of the package (two number. the first number for pounds and the second number for ounces). The program then displays the cost for the shipment. Run the program for continuous for three times to calculate following cases:

(a) Ground 3 lb 8 oz

(b) Express 0 lb 6 oz

(c) Overnight 6 lb 11 oz

Given that: 1 lb = 16 oz

Question 2

The handicap differential (HCP) for a round of golf is calculated from the formula:

HCP = ((Score - Course Rating)/course Slope ) x113

The course rating and the slope are measures of how difficult a particular course is. A golfers handicap is calculated from a certain number N of their best (lowest) handicap scores according to the Table 1.

For example, if 13 rounds have been played, only the best five handicaps are used. A handicap cannot be computed for the fewer than five rounds. If more than 20 rounds have been played, only the 20 most recent results are used.

Once the lowest N handicap differentials have been identified, they are averaged and then rounded down to the nearest tenth. The result is player's handicap.

(a) Write a MATLAB program in a script file that calculates a person's handicap. The program asks the user to enter the golfers record in a three columns matrix where the first column is the course rating, the column is the course slope, and the third is the player's score. Each row corresponds to one round. The program displays the person's handicap, the number of rounds have been played and the three column matrix.

Write a report to explain the method you are using.

(b) Execute the program for the players with the following records

(i)

Rating

Slope

Score

72.2

119

71

71.6

122

73

74.0

139

78

68.2

125

69

70.2

130

74

69.6

109

69

66.6

111

74

(ii)

Rating

Slope

Score

71.6

122

85

72.8

118

87

69.7

103

83

70.3

115

81

70.9

116

79

72.3

117

91

71.6

122

89

70.3

115

83

72.8

118

92

70.9

109

80

73.1

132

94

68.2

115

78

74.2

135

103

71.9

121

84

72.2

119

71

71.6

122

73

74.0

139

78

68.2

125

69

70.2

130

74

69.6

109

69

66.6

111

74

71.4

107

72

Question 3

A railway wagon, moving with velocity v, strikes a viscously damped buffer. The equation of motion is given by:

m - dv/dt = -cv

Where v(t) is the velocity of the wagon at time t. Assume that the values of the mass m, damping c, and initial velocity v(0) as m = 5000 kg, c = 15000 Ns/m, and v(0) = 3 m/s

(a) Write a MATLAB code to calculate the velocity of the wagon at t = 2 second by using 4th order Runge-Kutta method, Euler Explicit and Euler Implicit. All plots must be plotted in the same figure. Start with the step size of 1. Your code must show the velocity with respective time for all three methods in the command window.

(b) Repeat your calculation in (a) with another two step sizes, i.e., 0.5 and 0.1. Discuss your solutions.

Section B

Question 1

Each of the two tanks shown in Figure 1 contain 100 gallons of water. The water in tank 1 contains 1000 grams of dissolved salt, while the water in tank 2 contains 100 grams of dissolved salt. At time t = 0, pipe 1 starts pumping pure water at the rate of 10 gallons/minute, while pipes 2, 3, and 4 start pumping mixed water at rates 15, 5, and 10 gallons/minute, respectively, in the directions indicated in Figure 1. The concentration of the tanks 1 and 2 are represent by the following differential equations:

dx/dt = 5/100y - 15/100x

dy/dt = 15/100x - 15/100y

where x(0) = 1000, y(0) = 100, x(t) is the amount of salt in tank 1 at time t, and y(t) is the amount of salt in tank 2 at time t

1275_Figure 1.jpg

Figure 1 - Two connected tanks with dissolved salt

(a) Apply 4th order Runge-Kutta (RK) method to find the concentration of the salt in the tanks at t = 3 mins with the step size of 1 (solve manually).

(b) Write a MATLAB code to find the concentration of the salt in the tanks at t = 50 mins with the step size of 1. List out all the RK solutions and plot the graph.

(c) Using the code in part (b), find the time (in 2 decimal places) when the concentration of both tanks are same by showing it in the graph.

(d) Using the same code in part (b), find the time (in 2 decimal places) when the concentration of both tanks is below 2. Display clearly your solution in the graph.

Request for Solution File

Ask an Expert for Answer!!
Other Engineering: Assignment - eng 2314 eng60104 - write a matlab script
Reference No:- TGS01609078

Expected delivery within 24 Hours