ISE212Engineering Computing:MATLAB Spring_2014

Homework #3 Due:Tuesday3/18/2014

Upload your HW3 assignments to the TA by going to Content in Blackboard:

1.In many engineering applications, it is necessary to have the surface of the metal components hard enough to resist wear and erosion, while having the core ductile and tough in order to withstand impact and shock loading. A common surface hardening process is called carburizing. Carburizing involves the diffusion of carbon into the surface layer of a steel component that has low-carbon content (less than 0.4%). This is achieved in industry by placing the component in a carbon-rich medium at elevated temperature. The diffusivity (in cm2/s) is a measure of how fast diffusion occurs, and can be modeled as:

D = D0e(–Q/ RT)

where:

D0 = diffusion coefficient

Q = activation energy, j/mole

R = ideal gas constant, 8.314 J/mole K

T = temperature, K

As iron is heated, it changes micro-structure, and its diffusion characteristics change. The values of D0and Q are shown in the table for carbon diffusing through each of iron’s structures:

Metal Type D0 (cm2/s)Q (J/mole K)

Alpha Fe (Body-Centered Cubic-BCC)> 0.0062 98,000

Gamma Fe (Face-Centered Cubic-FCC)> 0.1800 150,000

Write an executable script file (m-file) that takes no input and returns a plot of diffusivity (y) versus inverse temperature (1/T) for Alpha Fe (BCC) and Gamma Fe (FCC)using the data provided. Provide a rectangular, semi-log (2), and log-log plot to see which represent the results best and allows a user to read values from the graph easily over a wide range of both temperatures and diffusivities. Let the temperature vary from room temperature:20OC to 1150 OC. Place all four plot variations on the same figure. Place x-labels only on the two bottom graphs to reduce clutter and add a legend only to the first plot. Your plot must assume the following qualities:

(Name your m-file>diffuse14.m).

grid on

plot Δ x = 5.0

Title:Diffusivity

x-axis label:Inverse Temperature, K-1 x 10-3

y-axis label: Diffusivitycm2/s

Alpha Fe curves should be in blue solid lines, Gamma Fe curves in red dashed lines.

(Make sure to use the correct units for temperature in your equation).

2.Suppose the following vector represents the number of robots ordered from your company each month over the last year:RobotsN =[2, 4, 5, 3, 7, 5, 9, 10, 12, 8, 8, 5].

All the numbers should be zero or positive.

(a) Use an if statement to check whether any of the values in the matrix are invalid. (Evaluate the whole matrix at once in a single if statement.) Send either the message “All valid” or “Invalid number found” to the screen, depending on the results of your analysis.

(b) Change the robots matrix to include at least one negative number, and check your program to make sure that it works for both cases.

Write an executable script file (m-file) that will execute the program described above.

(Name your m-file: robots14.m).

3.Write an executable script file (m-file) that prompts the user to enter the temperature outside in degrees Fahrenheit. If the temperature entered is 70°F or higher, send a message to the command window telling the user to wear their wildfire shorts. If the temperature entered is between 60°F and 70°F, send a message to the command window telling the user that it is a nice beautiful day. If the temperature is equal to or below 60°F, but greater than 30°F, send a message to the command window telling the user to wear a leather jacket. If the temperature is less than or equal to 30°F, send a message to the command window telling the user that he or she must be in BinghamtonNY.
(Name your m-file>BeachDay14.m).

4.In basic algebra, thequadratic formulais the solutionof the quadratic equation. There are other ways to solve the quadratic equation instead of using the quadratic formula, such as factoring, completing the square, or graphing. However, using the quadratic formula is often the most convenient way.

The general quadratic equation is:

Write an executable script file (m-file) that prompts the user to enter values for the coefficients constants a, b, and cfor a quadratic equation then outputs the solutions (roots), if any.

(Name your m-file>Quadratic14.m).

THE END