ME 1020: ENGINEERING PROGRAMMING WITH MATLAB

Transcription

Wright State UniversityDepartment of Mechanical and Materials EngineeringSpring 2016ME 1020: ENGINEERING PROGRAMMING WITH MATLABMID-TERM EXAM 1Open Book, Closed NotesCreate a Separate MATLAB Script File for Each ProblemSubmit all MATLAB files (.m) to Dropbox on PilotEach MATLAB File Must Have the Following Header:PRINT YOUR NAME:CIRCLE ONE:GRADE MY EXAMDO NOT GRADE MY EXAMProblem 1 (2 Points): Create a MATLAB Script File to calculate the following equation (πœƒ 32/πœ‹ )𝑦 πœ‹[ πœ‹ cosh 1 { (πœƒ 2πœ‹)}] πœ‹/(2 7πœ‹)Problem 2 (6 Points): Create a MATLAB Script File to plot an astroid on the π‘₯𝑦 plane over the parametricinterval 2πœ‹ 𝑑 2πœ‹, whereπ‘₯ cos3 (𝑑) ,𝑦 sin3 (𝑑)Also, plot the catacaustic of the astroid on the same plot over the same range for 𝑑:π‘₯ cos(𝑑) [8 5 cos(2𝑑) 3 cos(6𝑑)]13 3 cos(4𝑑)4sin3(𝑑) [7 6 cos(2𝑑) 3 cos(4𝑑)]𝑦 13 3 cos(4𝑑)Make sure to use enough points to create smooth curves. Provide a plot title, labels for the axes, and a legendfor the two curves.Problems 3 and 4 are on the back of this page.

Problem 3 (6 Points): Type this array into a MATLAB Script File to carry out the following instructions:1 2𝐀 [4 57 836]9a. Use MATLAB to create an array 𝐁 by copying the elements from the second and third columns of array𝐀 (1 Point).b. Use MATLAB to create an array 𝐂 by copying the elements from the first and second rows of array 𝐀(1 Point).c. Use MATLAB’s Matrix Multiplication (*) to calculate 𝐃 𝐁 𝐂 (1 Point).d. Use MATLAB’s max function to create a vector that contains the maximum values of each column of𝐃 (1 Point).e. Use MATLAB’s min function to create a vector that contains the minimum values of each row of 𝐃 (1Point).f. Use MATLAB’s Matrix Multiplication (*) to multiply the two vectors found in parts d and e (1 Point).Problem 4 (6 Points): The quenching process is used to cool metals in a liquid bath. The initial temperature ofa copper sphere is 𝑇𝑖 500 K, and the temperature of the liquid bath is 𝑇𝑏 273 K. The temperature of thecopper sphere at any time during the quenching process is given by𝑇 𝑇𝑏 (𝑇𝑖 𝑇𝑏 ) exp [ β„Žπ΄π‘‘]πœŒπΆπ‘ 𝑉where β„Ž 100 W/(m2-K) is the heat transfer coefficient, 𝜌 8940 kg/m3 is the density of copper, and 𝐢𝑝 380 J/(kg-K) is the specific heat of copper. The surface area and volume of a sphere are𝐴 4πœ‹π‘Ÿ 2 ;𝑉 4πœ‹π‘Ÿ33where π‘Ÿ 0.0015 m is the radius of the sphere. Create a MATLAB Function File that uses the followingvariables as inputs: 𝑇𝑖 , 𝑇𝑏 , β„Ž, π‘Ÿ, 𝜌, 𝐢𝑝 and 𝑑. The output of the Function File is to be the temperature of the sphere.Create a MATLAB Script File that calls the Function File to plot the temperature of the sphere versus time from0 𝑑 150 seconds. Provide a plot title and labels for the axes.

% Mid-Term Exam 1, ME 1020, Spring 2016% Problem 1: Scott Thomasclccleartheta 32/piy -pi*(-pi*acosh(-(theta-2*pi))) (-pi/(2-7*pi))theta 10.1859y -4.3672 1.5315iPublished with MATLAB R2012b21 033 12 1

% Mid-Term Exam 1, ME 1020, Spring 2016% Problem 2: Scott ThomasclcclearcloseN 10000;t linspace(-2*pi,2*pi,N);x (cos(t)). 3;y (sin(t)). 3;xr cos(t).*(8 5*cos(2*t) 3*cos(6*t))./(13 3*cos(4*t));yr 4*(sin(t)). 3.*(7 6*cos(2*t) 3*cos(4*t))./(13 3*cos(4*t));figureplot(x,y, xr,yr), xlabel('x'), ylabel('y'), title('Problem 2: Scott 'Best')Published with MATLAB R2012b6 5 4 3 2 1 036 2 5 3 0 0 0

% Mid-Term Exam 1, ME 1020, Spring 2016% Problem 3: Scott ThomasclcclearABCDEFG [1 2 3; 4 5 6; 7 8 9]A(:,2:3)A(1:2,:)B*Cmax(D)min(D')E*F'A 4B C D E F G 5817Published with MATLAB R2012b

65 4 3 2 1 018 16 7 4 0 0 0

% Mid-Term Exam 1, ME 1020, Spring 2016% Problem 4: Scott ThomasclcclearN 1000;t linspace(0,150,N);h 100;% W/m 2-Krho 8940;% kg/m 3cp 380;% J/kg-Kr 0.0015;% mTi 500;% KTb 273;% KT ime t (seconds)'), ylabel('Temperature T (K)')title('Mid-Term Exam 1, ME 1020, Spring 2016, Problem 4')ans 273.0332Published with MATLAB R2012b

function [ T ] quench( Ti,Tb,h,r,rho,cp,t )% Scott ThomasA 4*pi*r 2;V 4*pi*r 3/3;T Tb (Ti - Tb)*exp(-(h*A*t)/(rho*cp*V));end6 5 4 3 2 1 029 5 3 3 1 4 0

ME 1020: ENGINEERING PROGRAMMING WITH MATLAB MID-TERM EXAM 1 Open Book, Closed Notes Create a Separate MATLAB Script File for Each Problem Submit all MATLAB files (.m) to Dropbox on Pilot Each MATLAB File Must Have the Following Header: PRINT