Create a single MATLAB script with each problem below as a separate section (hint: %%). 1. Create a new script 2. Create a comment section at the top with your name, date, HW#, class, etc. 3. The first script commands should erase all the workspace data, command window output, and close all figures. 4. Create separate sections (%% ) for each problem
Problem 1 (20 pts)
Problem 2 (20 pts)
Problem 3 (20 pts) The power series for sin(x) is given by
The script on the next slide will compute this power series for a given value of x What causes the loop to terminate? ? How many terms were needed?
How accurate is the series for =
2
1
Problem 4 (20 pts) A company wants to locate a distribution center that will serve six of its major customers in a 30×30 mi area. The locations of the customers relative to the southwest corner of the area are given in the following table in terms of (x, y) coordinates (the x direction is east; the y direction is north). Also given is the volume in tons per week that must be delivered from the distribution center to each customer. Then weekly delivery cost ci for customer i depends on the volume Vi and the distance di from the distribution center. For simplicity we will assume that this distance is the straight-line distance. (This assumes that the road network is dense.) The weekly cost is given by ci = 0.5dV, i = 1, … ,6, Find the location of the distribution center (to the nearest mile) that minimizes the total weekly cost to service all six customers.
2
Problem 5 (20 pts) Many applications require us to know the temperature distribution in an object. For example, this information is important for controlling the material properties, such as hardness, when cooling an object formed from molten metal. In a heat-transfer course, the following description of the temperature distribution in a rectangular metal plate is often derived.
The temperature is held constant at 1 on three sides and at 2 on the fourth side. The temperature as a function of the xy coordinates shown is given by
where
Use the following data: 1 = 70℉, 2 = 200℉, and W=L=2ft. a. The terms in the preceding series become smaller in magnitude as n increases. Write a program to verify this fact for n=1, …., 19 for the center of the plate (x=y=1) b. Using x=y=1 , write a program to determine how many terms are required in the series to produce a temperature calculation that is accurate to within 1 percent. (That is, for what value of n will the addition of the next term in the series produce a change in T of less than 1 percent?) Use your physical insight to determine whether this answer gives the correct temperature at the center of the plate. c. Modify the program from part b to compute the temperatures in the plate; use a spacing of 0.2 for both x and y.
3
Bonus question (20 pts) Place your name in the right corner as shown in the figure. For this assignment, the code for the plots are given and you are expected to create a user defined function that places your name in the corner of any plot.
4
Turn in the following: 1. A Word (.doc, .docx) document created using the MATLAB publish feature to publish your script. 2. Your .m script file(s) (these are separate files from the document above). Make sure you use plenty of comments. Before submitting, rename all *.m files to have a .txt extension. For example, rename MyHW6.m to MyHW6.txt before submitting. Submit all files electronically on Blackboard. See syllabus for late assignment policy.
Late submissions will receive a 10% deduction! No submissions will be accepted after one day!
5




