Uploaded by jessiega

HW02 Skills Problems

advertisement
Homework 2 - Basics 1
Function Name: heNeedsSomeMilk
Inputs:
1. (double) Height of bucket in feet
2. (double) Diameter of bucket in feet
Outputs:
1. (double) Volume of bucket in cubic feet
Topics: (functions), (exponents)
Function Description:
Given the height and diameter of a cylindrical bucket, calculate the volume of the bucket.
Round your final answer to the first decimal place. Remember that the volume of a cylinder can
be found using the following formula:
Example:
height = 2.2;
diameter = 1.8;
volume = heNeedsSomeMilk(height, diameter)
volume →
5.6000
Notes:
● π can be represented in MATLAB by typing pi. Do not use 3.14 or any other rounded
numerical representation of pi for this problem.
● The round() function will be important! Note that MATLAB might display something like
5.6000 instead of 5.6, but if you utilize the round() function properly it will be okay!
Hints:
● Remember that the volume formula uses the radius of the cylinder, not the diameter!
Homework 2 - Basics 1
Function Name: homeOnTheRange
Inputs:
1. (double) Launch velocity in meters per second, v
2. (double) Launch angle, , in radians
Outputs:
1. (double) Projectile range in meters
Topics: (functions), (trigonometry)
Function Description:
Given the launch velocity and launch angle, calculate the range of a projectile (in meters)
based on the range equation given. Round your result to two decimal places.
Example:
velocity = 35;
angle = pi ./ 4;
range = homeOnTheRange(velocity, angle)
range →
124.87
Notes:
● g has a value of 9.81 meters per second squared.
● The sin() function might be helpful.
● v and will always be positive.
Hints:
● Don't forget to round!
Homework 2 - Basics 1
Function Name: cowculator
Inputs:
1. (double) X-coordinate of cow number 1
2. (double) Y-coordinate of cow number 1
3. (double) X-coordinate of cow number 2
4. (double) Y-coordinate of cow number 2
Outputs:
1. (double) Distance between the two cows
Topics: (basic arithmetic), (square root)
Function Description:
Given the X and Y coordinates of two points, compute the distance between them using
the distance formula, as shown below:
Round your answer to two decimal places.
Example:
cow1X
cow1Y
cow2X
cow2Y
=
=
=
=
3;
4;
-2;
5;
dist = cowculator(cow1X, cow1Y, cow2X, cow2Y);
dist →
5.10
Notes:
● The sqrt() and round()functions may be helpful.
Homework 2 - Basics 1
Function Name: lawOfSwines
Inputs:
1. (double) Length of side a
2. (double) Angle A, in degrees
3. (double) Angle B, in degrees
Outputs:
1. (double) Length of side b
Topics: (multiplication/division), (trigonometry)
Function Description:
In trigonometry, the Law of Sines is written as follows, where a and b are the lengths of
the sides of a triangle, and A and B are the angles corresponding to the respective sides:
Given the length of side a, and both angles A and B, calculate the length of side b. Round your
final answer to three decimal places.
Example:
sideA = 10;
angleA = 106;
angleB = 31;
sideB = lawOfSwines(sideA, angleA, angleB)
sideB →
5.358
Notes:
● sin() and cos() work with radians, whereas sind() and cosd() work with degrees.
● The round() function may be helpful.
Hints:
● Consider rearranging the above equation to solve for the length of side b.
Homework 2 - Basics 1
Function Name: manyCows
Inputs:
1. (double) The current population after a time t has elapsed
2. (double) The time elapsed, t
Outputs:
1. (double) The initial population
Topics: (multiplication/division), (exponentials/exp())
Function Description:
Given the current population and how long the population has been growing, determine
the initial population using the exponential growth population model. The rate of growth, r, will
always be 0.2. Utilize the following formula:
Where P is the current population, P0 is the initial population, e is Euler's Number, r is the rate of
growth, and t is the time elapsed. Round your answer to the nearest whole number.
Example:
pop = 100;
time = 3;
initPop = manyCows(pop, time)
initPop →
55
Notes:
● Type "help exp" into the command window!
● All time (t) and population (P) values will be greater than or equal to zero.
Download