Write a test script that tests all four of these problems. You should run the
functions and/or scripts for each of the problems using values that adequately
test your solution to the problem. Turn this script in with the rest of your
files to WebCT.
In each of your files, be sure to place comments describing the function where applicable and include the necessary header information for each file as you did for each file in hw2.
Make sure your submission has the following files:
In addition, be sure you SUBMIT the assignment to WebCT and not simply upload it. A collection of uploaded but unsubmitted files is not gradable.
In forcasting events such as weather, a technique called a "moving average" is often used to look for patterns in data. Create a script called movingAverage.m that will prompt the user for five (5) numbers and place them in an array.
After each input from the user, calculate the current average of the array and store it in a second array. Done properly, the indexes will line up (i.e. after the third value is placed in the third position of the first array, the average of the first three values will be placed in the third position of the second array).
Each of your arrays should have five values. Plot both of these arrays against an array containing the integers 1 through 5 (displaying both on one graph).
Given two (2) 3-D Vectors compute the angle (in degrees) between them by writing a function named vectorAngle that takes in 2 vectors as parameters. These vectors will be arrays with three elements: one element for each coordinate of a 3d point. You should include two local functions in your solution.
The formula for the cross product of two vectors is
A x B = [A2*B3 - A3*B2 , A3*B1 - A1*B3, A1*B2 - A2*B1]
where A1, A2, A3, B1, B2, and B3 each represent the coordinate of vectore A and B along the x, y, and z axes. Note that A x B resultes in a new vector.
The formula for the magnitude of a cross product given to vectors is
|| A x B || = ||A|| * ||B|| * sin(theta)
where A and B are vectors and theta is the angle between them. ||...|| denotes magnitude
Remember the magnitude of a vector is simply the distance between two points, which you used in HW2.
The manager of a movie theater has complete freedom to set ticket prices. However, the more he charges, the less people come to see the movies. He did an experiment and discovered the following:
|
Write a function named attendanceCount that takes in one parameter: the cost of a single ticket. Calculate and return the attendance for a given ticket price.
Write a function named businessCost that takes in the cost of a single ticket. Calculate the cost of running the theater for that ticket price. The business cost includes the cost of renting the movie and the cost of cleaning up.
Write a function named theaterProfit that takes in the cost of a single ticket. Calculate the profit from the theater at the given ticket price.
Write a script named hw3prob3.m to prompt the user for a ticket price, and calculates the profit from the theater. For now ignore that fact that partial people really don't exsist.
You may assume the ticket price will never be higher than $5.
When a metal tube is heated, the heat energy is not distroduted evenly throughtout the tub's crosssection. If the tube has inner radius ri and outer radius ro, with corrosponding tempuratures Ti (inner) and To (outer), then the tempurature anywhere within the mass of the tube can be calulated with the following equations.
T = To + (Ti-To)*R/Ri
R = log (ro/r)
Ri = log (ro/ri)
Create a function called temperaturePlot that creates a radius array consisting of 100 evenly distributed values between ri and ro— you will find the linspace comand helpful here. tempaturePlot should accept 4 parameters in the order ri, ro, Ti, To. It should hen plot the temperature at each of these points against the radius. Add sutable headers, labels, and one other thing you find useful— this one other thing can be anything you feel is useful in the graph.
Matlab's log function is really math's natural log (ln). This problim calls for natural log so please type log in Matlab.