114 Chapter 3 Built-In MATLAB® Functions
PROBLEMS
Elementary Math Functions
3.1 Find the cube root of - 5, both by using the nthroot function and by rais-ing - 5 to the 1/3 power. Explain the difference in your answers. Prove that both results are indeed correct answers by cubing them and showing that they equal - 5.
3.2 MATLAB® contains functions to calculate the natural logarithm ( log), the logarithm to the base 10 (log10), and the logarithm to the base 2 (log2). However, if you want to find a logarithm to another base-for example, base b-you'll have to do the math yourself with the formula
1 2 loge 1x2 logb x 5 loge 1b2
What is the logb of 10 when b is defined from 1 to 10 in increments of 1?
3.3 Populations tend to expand exponentially, that is,
P 5 P0 ert
where
P = current population P0 = original population
r = continuous growth rate, expressed as a fraction t = time.
If you originally have 100 rabbits that breed at a continuous growth rate of 90% 1r 5 0.92 per year, find how many rabbits you will have at the end of 10 years.
3.4 Chemical reaction rates are proportional to a rate constant k that changes with temperature according to the Arrhenius equation
k 5 k0e2Q>RT
For a certain reaction,
Q 5 8000 cal>mol
R 5 1.987 cal>mol K
k0 5 1200 min21
Find the values of k for temperatures from 100 K to 500 K, in 508 increments.
Create a table of your results.
3.5 Consider the air-conditioning requirements of the large home shown in Figure P3.5.
The interior of the house is warmed by waste heat from lighting and electrical appliances, by heat leaking in from the outdoors, and by heat generated by the people in the home. An air-conditioner must be able to remove all this thermal energy in order to keep the inside temperature from rising. Suppose there are 20 light bulbs emitting 100 J/s of energy each and four appliances emitting 500 J/s each. Suppose also that heat leaks in from the outside at a rate of 3000 J/s.
(a) How much heat must the air-conditioner be able to remove from the home per second?
(b) One particular air-conditioning unit can handle 2000 J/s. How many of these units are needed to keep the home at a constant temperature?
3.6. (a) If you have four people, how many different ways can you arrange them in a line?
(b) If you have 10 different tiles, how many different ways can you arrange them?
3.7. (a) If you have 12 people, how many different committees of two people each can you create? Remember that a committee of Bob and Alice is the same as a committee of Alice and Bob.
(b) How many different soccer teams of 11 players can you form from a class of 30 students? (Combinations-order does not matter).
(c) Since each player on a soccer team is assigned a particular role, order does matter. Recalculate the possible number of different soccer teams that can be formed when order is taken into account.
3.8 There are 52 different cards in a deck. How many different hands of 5 cards each are possible? Remember, every hand can be arranged 120 (5!) differ-ent ways.
3.9 Very large prime numbers are used in cryptography. How many prime num-bers are there between 10,000 and 20,000? (These aren't big enough primes to be useful in ciphers.) (Hint: Use the primes function and the length command.)
Trigonometric Functions
3.10 Sometimes it is convenient to have a table of sine, cosine, and tangent val-ues instead of using a calculator. Create a table of all three of these trigono-metric functions for angles from 0 to 2p, with a spacing of 0.1 radian. Your table should contain a column for the angle and then for the sine, cosine, and tangent.
3.11 The displacement of the oscillating spring shown in Figure P3.11 can be described by
Find the displacement x for times from 0 to 10 seconds when the maximum
displacement A is 4 cm, and the angular frequency is 0.6 radian/s. Present
A your results in a table of displacement and time values.
3.12 The acceleration of the spring described in the preceding exercise is
a 5 - Av2 cos1vt2
Find the acceleration for times from 0 to 10 seconds, using the constant values from the preceding problem. Create a table that includes the time, the displacement from corresponding values in the previous exercise, and the acceleration.
3.13 You can use trigonometry to find the height of a building as shown in Figure P3.13. Suppose you measure the angle between the line of sight and the horizontal line connecting the measuring point and the building. You can calculate the height of the building with the following formulas:
tan1u2 5 h>d
h 5 d tan1u2
Assume that the distance to the building along the ground is 120 m and the angle measured along the line of sight is 308 638. Find the maximum and minimum heights the building can be.
3.14 Consider the building from the previous exercise.
(a) If it is 200 feet tall and you are 20 feet away, at what angle from the ground will you have to tilt your head to see the top of the building? (Assume that your head is even with the ground.)
(b) How far is it from your head to the top of the building?
3.15 Consider the following table of data representing temperature readings in a reactor:
Your instructor may provide you with a file named thermocouple.dat, or you may need to enter the data yourself.
Use MATLAB® to find
(a) The maximum temperature measured by each thermocouple.
(b) The minimum temperature measured by each thermocouple.
3.16 The range of an object shot at an angle u with respect to the x-axis and an initial velocity v0 (Figure P3.16) is given by 2 Range 5 vg0sin12u2
for 0 ... u ... p>2 and neglecting air resistance. Use g 5 9.81 m>s2 and an initial velocity v0 of 100 m/s. Show that the maximum range is obtained at approximately u 5 p>4 by computing the range in increments of p>100 between 0 ... u ... p>2. You won't be able to find the exact angle that results in the maximum range, because your calculations are at evenly spaced angles of p>100 radian.
3.17 The vector G5[68, 83, 61, 70, 75, 82, 57, 5, 76, 85, 62, 71, 96, 78, 76, 68, 72, 75, 83, 93] represents the distribution of final grades in a dynamics course. Compute the mean, median, mode, and standard deviation of G. Which better represents the "most typical grade," the mean, median, or mode? Why? Use MATLAB® to determine the number of grades in the array (don't just count them) and to sort them into ascending order.
3.18 Generate 10,000 Gaussian random numbers with a mean of 80 and stand-ard deviation of 23.5. (You'll want to suppress the output so that you don't overwhelm the command window with data.) Use the mean function to confirm that your array actually has a mean of 80. Use the std function to confirm that your standard deviation is actually 23.5.
3.19 Use the date function to add the current date to your homework.
Random Numbers
3.20 Many games require the player to roll two dice. The number on each die can vary from 1 to 6.
(a) Use the rand function in combination with a rounding function to cre-ate a simulation of one roll of one die.
(b) Use your results from part (a) to create a simulation of the value rolled with a second die.
(c) Add your two results to create a value representing the total rolled dur-ing each turn.
(d) Use your program to determine the values rolled in a favorite board game, or use the game shown in Figure P3.20.
3.21 Suppose you are designing a container to ship sensitive medical materials between hospitals. The container needs to keep the contents within a speci-fied temperature range. You have created a model predicting how the con-tainer responds to the exterior temperature, and you now need to run a simulation.
(a) Create a normal distribution (Gaussian distribution) of temperatures with a mean of 70°F and a standard deviation of 2°, corresponding to a 2-hour duration. You'll need a temperature for each time value from 0 to 120 minutes. (That's 121 values.)
Problems 119
(b) Plot the data on an x-y plot. Don't worry about labels. Recall that the MATLAB® function for plotting is plot(x,y).
(c) Find the maximum temperature, the minimum temperature, and the times at which they occur.
3.22 Consider the circuit shown in Figure P3.22, which includes the following:
• A sinusoidally varying voltage source, V.
• An inductor, with an inductance, L.
• A capacitor, with a capacitance, C.
• A resistor, with a resistance, R.
We can find the current, I, in the circuit by using Ohm's law (generalized for alternating currents),
where ZT is the total impedance in the circuit. (Impedance is the AC corollary to resistance.)
Assume that the impedance for each component is as follows:
(Electrical engineers usually use j instead of i for imaginary numbers.) Find the current, I, in the circuit. You should expect a complex number
as a result. Enter the complex values of impedance into your calculations using the complex function.
3.23 Impedance is related to the inductance, L, and the capacitance, C, by the following equations
(a) Find the impedance for the capacitor (ZC) and for the inductor (ZL).
(b) Find the total impedance
ZT 5 ZC 1 ZL 1 R
(c) Find the current by solving Ohm's law for I.
V 5 IZT
(d) Electrical engineers often describe complex parameters using polar coordinates, that is, the parameter has both an angle and a magnitude. (Imagine plotting a point on the complex plane, where the x-axis repre-sents the real part of the number, and the y-axis represents the imagi-nary part of the number.) Use the abs function to find the magnitude of the current found in part c, and use the angle function to find the corresponding angle.
Attachment:- Chapter_3_-_Homework.pdf