# Problems Matlab Help

Problems

You can find the answers to problems marked with an asterisk at the end of the text.

1. The following list gives the measured gas mileage in miles per gallon for 22 cars of the same model. Plot the absolute frequency histogram and the relative frequency histogram
23 25 26 25 27 25 24 22 23 25 26
26 24 24 22 25 26 24 24 24 27 23
2. Thirty pieces of structural timber of the same dimensions were subjected to an increasing lateral force until they broke. The measured force in pounds required to break them is;given\in.the following list. Plot the absolute frequency histogram? Try bin widths of 50, 100,·and 200 Ib.Which gives the-most meaningful histogram? Try to find a better value for the bin width.
243   236   389   628   143   417   205
404   464   605   137   123   372   439
497   500   535   577   441   231   675
132   196   217   660   569   865   725′
457  347
3. The following list gives the measured breaking force in newtons for a sample Of 60 pieces of certain type of cord. Plot the absolute frequency histogram. Try bin widths of 10, 30, and 50 N. Which gives the most meaningful histogram? Try to find a better value for the bin width.
257  236   313  281  288  225  216  250  259  323  280  205
279  159   276  354  278  221  192  281  204  361  321  282
254  273   334  172  240  327  261  282  208  213  299  318
356  269   355  232  275  234  267  240  331  222  370  226
4. *If you roll a balanced pair of dice 300′ times, how many times would you expect to obtain a sum of 8? A sum of either 3, 4, or 5? A sum of less than 9?
5. For the data given in Problem 1,
a. Plot the scaled frequency histogram.
b. Compute the mean and standard deviation and use them to estimate the lower and upper limits of gas mileage corresponding to 68 percent of cars of this model. Compare these limits with those of the data.
6. For the data given in Problem 2
a. Plot the scaled frequency histogram.
b. Compute the mean and standard deviation and use them to estimate the lower and upper limits of strength corresponding to 68 percent and to 96 percent of such timber pieces. Compare these limits with those of the data.
7. For the data given in Problem 3
a. Plot the scaled frequency histogram.
b. Compute the mean and standard deviation, and use them to estimate the lower and upper limits of breaking force corresponding to 68 percent and 96 percent of cord pieces of this type. Compare these limits with those of the data.
8. *Data analysis of the breaking strength of a certain fabric shows that it is normally distributed with a mean of 200 lb and a variance of 9.
a. Estimate the percentage of fabric samples that will have a breaking strength no less than 194 lb.
b. Estimate the percentage of fabric samples that will have a breaking strength no less than 197 Ib and no greater than 203 lb.
9. Data from service records shows that the time to repair a certain machine is normally distributed with a mean of 50 min and a ‘standard deviation of 5 min. Estimate how often it will take more than 60 min to repair a machine.
10. Measurements of a number of fittings show that the pitch diameter of the thread is normally distributed with a mean of 5.007 mm and a standard deviation of 0.005 mm. The design specifications require that the pitch diameter must be 5 ± 0.01 mm. Estimate the percentage of fittings that will be within tolerance.
11. A certain product requires that a shaft be inserted into a bearing. Measurements show that the diameter d) of the cylindrical hole in the bearing is normally distributed with a mean of 3 erm with a variance of 0.0064. The diameter d2 of the shaft is normally distributed with a mean of 2.96 em and a variance of 0.0036.
a. Compute the mean and the variance of the clearance c =d1 – d2.
b. Find the probability that a given shaft will not fit into the bearing.
(Hint: Find the probability that the clearance is negative.)
12. A shipping pallet holds 10 boxes. Each box holds 300 parts of different types. The part weight is normally distributed with a mean of 1 Ib and a standard deviation of 0.2 lb.
a. Compute the mean and standard deviation of the pallet weight.
b. Compute the probability that the pallet weight will exceed 3015 lb.
13. A certain product is assembled by placing three components end to end. The components’ lengths are L1, L2 and L3. Each component is manufactured on a different machine, so the random variation in their lengths is independent of each other. The lengths are normally distributed with means of 1,2, and 1.5 ft and variances of 0.00014,0.0002, and 0.0003, respectively.
a. Compute the mean and variance of the length of the assembled product.
b. Estimate what percentage of assembled products will be no less than 4.48 and no more than 4.52 ft in length.
14. Use a random number generator to produce 1000 uniformly distributed numbers with a mean of 10, a minimum of 2, and a maximum of 18. Obtain the mean and the histogram of these numbers and discuss whether or not they appear uniformly distributed with the desired mean.
15. Use a random number generator to produce 1000 normally distributed numbers with a mean of 20 and a variance of 4. Obtain the mean, variance, and the histogram of these numbers and discuss whether or not they appear normally distributed with the desired mean and Variance.
16. The mean of the sum (or difference) of two independent random variables equals the sum (or difference) of their means, but the variance is always the sum of the two variances. Use random number generation to verify this statement for the case where z = x + y, where x and y are independent and normally distributed random variables. The mean and variance of x are µx = 10 and σx² = 2. The mean and variance of y are µy = 15 and σy² = 3. Find the mean and variance of z by simulation and compare the results with the theoretical prediction. Do this for 100, 1000, and 5000 trials.
17. Suppose that z = x y, where x and y are independent and normally distributed random variables. The mean and variance of x are µ.x = 10 and = 2. The mean and variance of y are µ.>’ = 15 and = 3. Find the mean and variance of z by simulation. Does µ  = µ x µ.> Does σz² = σx² σy² Do this for 100, loop, and 5000 trials.
18. Suppose that y = x², where x is a normally distributed random variable with a mean and variance of µx = 0 and  σx² = 4. Find the mean
and variance of y by simulation. Does µy = µx ? Does σy = σx²? Do this
for 100, 1000, and 5000 trials.
19. *Suppose you have analyzed the price behavior of a certain stock by plotting the scaled frequency histogram of the price over a number of months. Suppose that the histogram indicates that the price is normally distributed with a mean $100 and a standard deviation of$5. Write a MATLAB program to simulate the effects of buying 50 shares of this stock whenever the price is below the $100 mean. and selling all your shares whenever the price is above$105. Analyze the outcome of this strategy over 250 days (the approximate number of business days in a year). Define the profit as the yearly income from selling stock plus the value of the stocks you own at year’s end, minus the yearly cost of buying stock. Compute the mean yearly profit you would expect to make, the minimum expected yearly profit, the maximum expected yearly profit, and the standard deviation of the yearly profit. The broker charges 6 cents per share bought or sold with a minimum fee’ of $40 per transaction. Assume you make only one transaction per day. 20. Suppose that data shows that a certain stock price is.normally distributed with a mean of$150 and a variance of 100. Create a simulation to compare the results of the following two strategies over 250 days. You start the year with 1000 shares. With the first strategy. every day the price is below $140 you buy 100 shares, and every day the price is above$160 you sell all the shares you own. With the second strategy, every day the price is below $150 you buy 100 shares, and every day the price is above$160 you sell all the shares you own. The broker charges 5 cents per share traded with a minimum of \$35 per transaction.
21. Write a script file to simulate 100 plays of a game in which you flip two coins. You win the game if you get two heads, lose if you get two tails, and .you flip again if you get one head and one tail. Create three user-defined functions to use in the script. Function flip simulates the flip of one coin, with the state s of the random number generator as the input argument, and the new state s and the result of the flip (0 for a tail and, 1 for a head) as the outputs. Function flips simulates the flipping of two coins, and calls flip. The input of flips is the state s, and the outputs are the new state s and the result (9 for two tails, 1 for a head and a tail, and 2 for two heads). Function mat ch simulates a turn at the game. Its input is the state s, and its outputs are the result (I for win, 0 for lose) and the new state s. The script should first reset the random number generator to its initial state, compute the state s, and then pass this state to the user-defined functions .
22. Write a script file to play a simple number guessing game as follows. The .script should generate a random integer in the range], 2, 3, … , 14, ]5. It should provide for the player to make repeated guesses of the number, and should indicate if the player has won or give the player a hint after each wrong guess. The responses and hints are:
¤   “You won,” and then stop the game .
¤   “Very close,” if the guess is within 1 of the correct number.
¤   “Getting close,” if the guess is within 2 or 3 of the correct number.
¤   “Not close,” if the guess is not within 3 of the correct number.
23. Interpolation is useful when one or more data points are missing. This situation often occurs with environmental measurements, such as temperature, because of the difficulty of making measurements around the clock. The following table of temperature versus time data.is missing readings at 5 and 9 hours. Use linear interpolation with MATLAB to estimate the temperature at those times.
Time (hours, P.M.)    1    2     3   4   5    6      7  8   9   10  11  12
Temperature (ºC)     10 12  18  24  ?   21  20 18  ?   15  13   8
24. The following table gives temperature data in °C as function of time of day and day of the week-at a specific location. Data is trussing for the I, entries marked with a question mark (?). Use linear interpolation with MATLAB to estimate·the temperature at the missing points.
25. Consider the robot arm shown in Figure 7.1-4. Suppose the arm lengths are Ll = 4 and L2 = 3 ft. Suppose we want the arm to start from rest at the location x(O) = 6, y(0) = 0 and stop three seconds later at
the location x(3) =0, y(3) = 4. Write a MATLAB program to compute the arm angle solution using two knot points, Write another program to compute the splines required to generate the two knot point and to plot the path of the robot’s hand: Discuss whether the hand s path deviates much from a straight line”
26. Computer-controlled machines are used to cut’ and to form metal and other materials when manufacturing products. These machine soften use cubic splines to specify the path to be cut or the contour of the part the shaped. The following coordinates specify the shape of a certain car’s front fender. Fit a series of cubic splines to the coordinates and plot the splines along with the coordinate points.
27. The following data is the measured temperature T of water flowing from a hot water faucet after it is turned on at time t =0.

a. Plot the data first connecting them with straight lines, and then with a cubic spline.
b. Estimate the temperature values at the following times using linear interpolation and then cubic-spline interpolation: t =0.6, 2.5,4.7, 8, 9.
c. Use both the linear and cubic-spline interpolations to estimate the time it will take for the temperature to equal the following values:
T =75,85,90, 105.

### Related Matlab Homework Assignments

Posted on July 15, 2015 in Probability Statistics and Interpolation