$30
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
Problem 2
Problem 3
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 accurate is the series for 𝑥 = ? How many terms were needed?
2
Problem 4
A company wants to locate a distribution center that will serve six of its major customers in a 30x30 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.5d𝑖V𝑖, 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.
Problem 5
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.
Bonus question
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.