TASK: When will a typical child weigh more than 1000 pounds, according to the Theron formula?
COMMENT: The Theron formula estimates LB, the weight in pounds of a child of age N years, as
lb = 2.20462 * e( 0.175571 * n + 2.197099 )
This formula is only approximate, and is generally used for children less than 10 years of age. However, since it's a formula, we can plug in any value of N we like and examine the results. The purpose of this exercise is to practice the use of the MATLAB WHILE statement, by using it to ask the question, "At what age in years would the Theron formula predict that a child would weigh more than 1000 pounds?"
INSTRUCTIONS:
It will be convenient to use the "DO FOREVER" version of the WHILE loop, because we don't start with anything to check. Before we begin the loop, we have to initialize N to its lowest possible value. We can take that to be 0. n = ? Now open a "DO FOREVER" while loop: DO FOREVER (how do you actually say this in MATLAB?) Evaluate the weight corresponding to this age. lb = ? If the weight exceeds 1000 pounds, we need to exit this loop. What MATLAB command will do that for us? If we don't exit the loop, then we need to move N to the next value that we want to check. end the loop Print the values of n and lb: fprintf ( ' At age %d, predicted weight is %g pounds > 1000.\n', n, lb );
CHECK: If your script is working correctly, then you should be able to determine that the child will exceed the weight of 220 pounds at age 14.
SUBMIT: Your work should be stored in a script file called "hw032.m". Your script file should begin with at least three comment lines:
% hw032.m % YOUR NAME % This script (describe what it does) % Add any comments here that you care to make.