Directions Use the Publish button/command in MATLAB to generate PDF files of your scripts. Submit your MATLAB files (.m)
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Directions Use the Publish button/command in MATLAB to generate PDF files of your scripts. Submit your MATLAB files (.m)
Part 1: Determine a suitable root finding method (100 pts) In this section, you will need to determine the best suited method to find the root of the equation, (i.e., determine p so that f(p) 0) using the thermodynamic constants in Table 1 as well as Equation 1. 2 Submissions for this 1. ii. iii. part include: Using an "if" statement, determine the values of a, b, and a based on your value of K (10) pts). Choose any one bracketing method and any one open method from the list below and use "for" loops to set them up (60 pts). a. Bracketing methods: i. Bisection method ii. False position method b. Open method: i. Newton Raphson method ii. Modified Newton Raphson method iii. Secant method Make a comparison between results obtained with both methods (30 pts). a. Provide a comparison of accuracy between the 2 methods using the error on the last iteration. b. Provide a comparison of computational efficiency between 2 methods using the Tic Toc method. c. Discuss which of the methods is the better option for root finding based on the comparisons.
9 2 Part 2: Automate the process using a function (100 pts) Now that you have determined the best root finding method, it is time for the next task! In this case, you will still work with Equation I but now both density p and temperature T, are going to vary. You will use your knowledge of functions to create MATLAB functions using the expression below: Submissions for this part include: i. ii. f(v.T.P.R)= iv. RT aa v-b v(v + b) P Equation 2 Use the script from Part 1 and convert it into a function file that (60 pts): a. Takes T, K, P, and R as inputs. A b. Determines for which p. f(v.T, P, R) 0 using your choice of root finding methods from Part 1. Recall: p = 1/v 2 c. Gives p as an output. In a separate .m file, use a "for" loop such that each iteration is a different 7' value and call the function file to determine p for each iteration. Create a matrix to store the values of T and p in after each iteration (20 pts). Run the .m file with T= 100: 1:300 K (10 pts). Plot p vs. 7, including axis labels, a title, grid lines, as well as a linewidth of 2 (10 pts). D
Part 3: Systems of linear equations (100 pts) Consider the following system of linear equations presented below in Equation 3: 10a-b+2c= 6 -a +11b-c + 3d = 25 2a-b+10c-c=-11 3b c + 8d 15 Equation 3 Submissions for this part include: Solve the system on linear equations using the Gauss-Seidel method in MATLAB. Consider a random initial guess (with values between 0 and 1) and perform iterations until the approximate percent error is less then 0.01 percent for all the unknowns in the system of linear equations (60 pts). HINT: a "while" loop will be helpful for this exercise. i. Confirm your answer is correct by solving the system of linear equations using a direct method such as Gauss elimination, Cramer's rule, or the inverse of the coefficient matrix. You should use MATLAB for this problem (40 pts).
Part 4: Nonlinear regression (100 pts) The data presented below in Table 2 follows the nonlinear relationship presented below in Equation 4. X y i. 11. 0.1 0.73 iii. y = axex Use MATLAB to determine the values of constants a and ß that minimize the sum of the squares of errors between the predictions of the nonlinear functional relationship and the data. iv. 0.2 0.4 1.27 1.41 Table 2: x and y data for nonlinear regression analysis 0.6 1.26 0.9 1.3 1.5 0.85 0.53 0.36 Submissions for this part include: Linearize the data (20 pts) Plot the linearized data and fit a linear equation to the linearized data. Be sure to include axis labels, a legend and title in your plot (30 pts). Equation 4 1.8 1.7 0.28 0.17 Use the linear regression coefficients to calculate the values of a and B. Display your answer using fprintf (30 pts). Plot the raw (nonlinearized) data against Equation 4 and comment on the goodness of the fit. As before, your plot should include axis labels, a legend and title (20 pts). 3
Part 5: Interpolation (100 pts) The volumetric flow rate of water in a long pipe is related to pressure using the Hagen-Poiseuille equation (Q=f(P)). However, this relationship is relatively inaccurate, and you decide to collect experimental data for interpolation instead. This data is presented below in Table 3 and MATLAB should be used for all parts of this exercise. Pressure P [kPa] 15 25 Flow Rate Q [mL/s] 15.4 39.6 53.3 58.4 66.1 73.2 Table 3: Experimental flow rate and pressure data 35 45 65 80 Submissions for this part include: i. Using a second-order interpolation polynomial and the method of linear equations, determine the flow rate of the water when the pressure P = 50 kPa (60 pts). ii. Plot the raw data, the interpolation polynomial, and the estimated flow rate at P = 50 kPa in a single figure. This figure should include axis labels, a legend, and title (40 pts).