PROBLEMS Matlab Help

Problems
You can find the answers to problems marked with an asterisk at the end of the text.
Section 3.1
1.* Suppose that y = – 3 +ix. For x =0, 1, and 2, use MATLAB to compute the following expressions. Hand check the answers.
a.’ Iyl
b. .JY\
c. (-5 -7i)y
d·6
2. * Let x = -5 – 8 i and y = 10 – Si: Use MATLAB to compute the following expressions. Hand check the answers.
a. The magnitude and angle of xy.
b. The magnitude and angle of x/y

3.* ‘Use MATLAB to find the angles corresponding to the following coordinates. Hand chec ‘the answers . .’
a. (x, y) = (5,8)
b. (x,y)=(~5,8)
‘c: (x, y) = (5, -8)
d. (x, y) = (-5, -8)

4. For several values of x, use MATLAB to confirm that sinh x = (eX – e-X)j2.
5. For several values ‘of x, use MATLAB to confirm that sinh -I x = In (x + .JX2+i), -00 < x < 00.
6. The capacitance of two parallel conductors of length L and radius r, separated by a distance d in air, is given by
7rEL C = —-:’–;–“7” In (d~r) where E is the permittivity of air (E = 8.854 X 10-12 F/m). Write a script file that accepts user input for d, L, and r, and computes and displays C. Test the file with the values: L ~ 1 m, r = 0.001 m, and d = O.OO4m.
7.* When a belt is wrapped around a cylinder, the relation between the belt forces on each side of the cylinder is
FI = F2e/J.fJ where 13 is the angle of wrap of the belt and J-L is the.friction coefficient. Write a script file that first prompts a user to specify 13, J-L. and F2 and then computes the force Fl. Test your program with the values 13 = 1300 J-L = 0.3, and·F2 = 100 N. (Hint: Be careful with f3!)

Section 3.2
8. . The MATLAB trigonometric functions expect their argument to be in radians. Write a function called sind that accepts an angle x in degrees and computes sin x. Test your function. .
9. Write a function that accepts temperature in degrees F and computes the corresponding value in degrees C. The relation between the two is Be sure to test your function.
10.* An object thrown vertically with a speed Vo reaches a height h at time t,
where
• ‘ 1
h = vot – gt2
2
Write and test a function that computes the time t required to reach a specified height h; for a given value of Vo. The function’s inputs should be h, vo, and g. Test your function for the case where h = 100m,
Vo = 50 mis, and g = 9.81 mls2. Interpret both answers:

11. A water tank consists of a cylindrical part of radius r and height h, and a hemispherical top. The tank is to be constructed to hold 500 m3 when filled. The surface area of the cylindrical part is 27rrh, and its volume is
1t r2 h. The surface area of the hemispherical top is given by 21T r2 , and its volume is given by 2rrr3/3. The cost to construct the cylindrical part of the tank is $300 per square meter of surface area; the hemispherical part costs

$400 per square meter. Use the fminbnd function to compute the radius that results in the least cost. Compute the corresponding height h.
12. A fence around a field is shaped as shown in Figure P12. It consists of a rectangle of length L and width W, and a right triangle that is symmetrical about the central horizontal axis of the rectangle. Suppose the width W is
known (in meters), and the enclosed area A is known (in square meters). Write a user-defined function file with Wand A as inputs. The outputs are the length L required so that the enclosed area is A, and the total length of
fence required. Test your function for the values W = 6 m and A = 80 m2. \

Capture

13. A fenced enclosure consists of a rectangle of length L and width 2R, and a semicircle of radius R, as shown in Figure P13. The enclosure is to be built to have an area A of 1600 ft2. The cost of the fence is $40 per foot
for the curved portion, and $30 per foot for the straight sides. Use the fminbnd function to determine with a resolution of 0.01 ft the values of R and L required to minimize the total cost of the fence. Also compute the
minimum cost.

Capture

14. Using estimates of rainfall, evaporation, and water consumption, the town engineer developed the following model of the water volume in the reservoir as a function of time. Vet) = 109 + 108(1 – e-I/Joo) – rt
where V is the water volume in liters, t is time in days, and r is the town’s consumption rate in liters/day. Write two user-defined functions. The first function should define the function Vet) for use with the fzero function.

The second function should use fzero to compute how long it will take for the water volume to decrease to x percent of its initial value of 109 L. The inputs to the second function should be x and r. Test your functions
for the case where x =50 percent and r = 107 U day.

15. The volume V and paper surface area A of a conical paper cup are given by where r is the .radius of the base of the cone and h is the height of the cone.
a. By eliminating h, obtain the expression for A as a function of rand V.
b. Create a user-defined function that accepts R as the only argument
and computes A for a given value of V. Declare V to be global within
the function. ‘
c. For V = 10 in.”, use the function with the fminbnd function to compute the value of r that minimizes the area A. What is the corresponding value of the height h? Investigate the sensitivity of the solution by plotting V versus r. How much can R vary about its . optimal value before-the area increases 10 percent above its minimum
value?
16. A torus is a shaped like a doughnut. If its inner radius is a and its outer radius: is b, its volume and surface area are given by
a. Create a user-defined function that computes V and A from the arguments a and b.
b. Suppose that the outer radius is constrained to be 2 in. greater than the inner radius. Write a script file that uses your function to plot A and V versus a for 0.25  a  4 in .1
17. Suppose it is known that the graph of the function Y =ax3 +bx2 +ex +d passes through four given points (Xj, Yj), i =1, 2, 3, 4. Write a user-defined function that accepts these four points as input and computes the
coefficients a, b, c, and d. The function should solve four linear equations in terms of the four unknowns a, b, c, and d. Test your function for the case where (Xj, Yj) = (-2, -20), (0, 4), (2, 68), and (4, 508); whose
answer is a = 7, b = 5,.c = -6, and d = 4. –

Section 3.3
18. Use the gen-plat function described in Section 3.3 to obtain two subplots, one plot of the function We-a over the range 0 ~ x ~ 2, and the other a plot of 5 sin(21l’ x /3) over the range 0 :5 x ~ 6.
19. Create an anonymous function for We-a and use it to plot the function over the range 0 x  2.

20. Create an anonymous function for 20×2 – 200x + 3 and use it a. to plot the function to determine the approximate location of its minimum, and
b. with the fminbnd function to precisely determine the location of the minimum.
21. Create four anonymous functions to represent the function 6 e3COSx \ which is composed of the functions h(z) = 6ez, g(y) = 3cosy, and I(x) = x2. Use the anonymous functions to plot 6 e 3cosx2 over the range 0 ~ x ~ 4.
22. Use a primary function with a sub-function to compute the zeros of the function 3×3 – 12×2 – 33x +90 over the range -10 ~ x ~ 10.
23. Create a primary function that uses a function handle with a nested function to compute the minimum of the function 20×2 – 200x + 3 over the range 0 ~ x ~ 10.
Section 3.4
24. Use a text editor to create a file containing the following data. Then use the load function to load the file into MATLAB, and use the mean function to compute the mean value of each column.
55 42 98
51 39 95
63 43 94
58 ’45 90
25. Enter and save the data given in Problem 24 in a spreadsheet. Then import the spreadsheet file into the MATLAB variable A. Use MATLAB to compute the sum of each column.

26. Use a text editor to create a file from the data given in Problem 24, but separate each number with a semicolon. Then use the Import Wizard to load and save the data in the MAlLAB variable A.
27. Use a text editor to create a file temperature. data  containing the temperature data given on page 175. Then use the Import Wizard to load and save the data in the MATLAB variable temperature. Compute the
mean value of each column.

Posted on July 27, 2015 in function and files

Share the Story

Back to Top
Share This