代写 R matlab Assignment 3C – New MATLAB ​(55 points) Part 1. (5 points)

Assignment 3C – New MATLAB ​(55 points) Part 1. (5 points)
Create a ​single ​MATLAB script that:
• Tells the user that this is a program which will determine the surface area and volume of three different types of solid objects: a right circular cone, a cylinder, and a rectangular prism (assume the rectangular prism can have a different width, depth and height).
• Asks the user for how many objects they want to find the surface area and the volume.
• Prompts the user for the type of object and then prompts the user for appropriate geometric inputs such as width, height, depth, or radius.
• Outputs the results of calculating the surface area and the volume of the objects to the screen.
• Informs the user when it has completed the requested number of calculations, and asks the user if they would like to run the program again. ​Note: Assume the cylinder is a solid right circular cylinder and include the base in the surface area of the cone.
Sample run: 3 objects, Cone, Cylinder and Prism. Parameters:
• ​Cone—radius = 5cm, height = 5cm
• ​Cylinder–radius = 5cm, height = 5cm
• ​Prism—length = 2cm, width = 3cm, height = 5cm

Part 2. (10 points)
Create ​three ​separate functions to find the surface and volume of each of the three different shapes. That is, one function to determine the surface area and volume of the cone, one function to determine the surface area and volume of a rectangular prism and one function to find the surface area and volume of a cylinder. Use the following names for your functions (note these
will be .m files): ​YOURPID_Coneareavol YOURPID_Cylareavol
YOURPID_Prismareavol
Sample run: Use the same parameters in the sample run for Part 1.
Part 3. (10 points)
Using what you have created in Part 2 (i.e. the functions), create a main program that prompts the user for all of the required inputs, stores them in a vector, calls on the appropriate function to make the necessary surface area and volume calculations and outputs the results to the command window. The results should be output to the command window using code written in the main program, not the functions created in Part 2. ​Note: this main program must also ask the user if they want to run the program again and then starts the program over if the user wants to continue.
Hint:Note vectors have indices and you can take advantage of that fact in this part of the problem.
Sample run: Use the same parameters in the sample run for Part 1.

Part 4. (25 points) (SEE MATLAB GRADER FOR CODE TESTING PORTION OF ASSIGNMENT)
25 points total
America’s Cup Data Revisited
Prepare the flowchart and MATLAB code for a function that will read time and position data (latitude and longitude) for two boats in a race from a file and will determine and output the number of times the boats are within 27 meters of each other (one boat length). The output will be saved in a data file that will be called ​boatsclose.txt​. This output file will contain the following line “​The boats come within 27 meters of each other ____ times.​” where the “____” is replaced by the number of times (i.e. number of time periods) the boats come within 27 meters of each other using fprintf to create this sentence.
The function input should be the variable ​DataName​ and the function output should be the variable ​TimesClose​, where ​DataName​ will be the filename for the data being loaded and TimesClose ​should be the number of times the boats were within 27 meters of each other.
Your function will also need to compute distances from latitude and longitude data, using the data provided from the America’s Cup race,
Finally, your function should create a plot (that displays to the screen) of distance between the boats as a function of time.
Title the plot “Plot of Race Boat Separation as a Function of Time”.Label the x-axis as “Time (sec)” and the y-axis as “Boat Separation Distance (m)”.
Completion of the code in MATLAB grader will not only enable you to validate your code, but will factor into grading of the code.
Helpful information ​computing distance​:
Use the following equations to turn latitude and longitude into actual distances using the
Haversine formula:

D = distance between two points given the latitude and longitude of those points R = earth’s radius (mean radius = 6,371km)
Δlat = lat​2−​ lat​1
Δlong = long2​ −​ long​1
a = sin2(Δlat/2) + cos(lat​1)​ *cos(lat​2)​ *sin2(Δlong/2)
c = 2*atan2(√a, √(1−a)) → ​the results of this equation must be in radians in order to be used in the formula for distance below
d = R*c
Haversine formula:
NOTE:
1. Type “help atan2” in the MATLAB command window to learn about the atan2 function.
2. You can use the MATLAB function length(A) to find out how many elements there are
in a an array or vector A.
3. Follow the flow chart guidelines provided in the ​Flowchart Guidelines Document​ ​on
Canvas.
The boat datasets contain latitude and longitude in degrees.
The data files provided on Canvas have headers that need to be stripped in order to load into MATLAB ​(​manually remove the headers in a program like WordPad)​ .

Submit to the Canvas site the following for each part of the assignment:
1. The listing of your m-file (copy and paste from the editor window). The first line of your code must be a comment with your class identifier, your name, and the date. You must also add comments to indicate the purpose of the problem. Add a few additional comments throughout the code to explain the main parts of the code.
2. A screenshot of your command window displaying a sample run. The sample run should show both your input and the output.
(Note – you can either copy and paste the output from the command window to your homework document or you can save an image of the command window showing the output and paste this in your homework document – text must be legible.) – You can run your function in the command window.
3. Flowchart of the program asked for in Part 1 (the surface area and volume program). Flowcharts are not required for the other parts.
4. For Part 4, include a screenshot of the contents of the output file generated from a run of the program using the provided data, and the plot of separation distance and time and answer the following question: W​ hat does the plot tell you about when the boats were within 27m of each other?
5. For Part 4, submit your final code on MATLAB grader as well–it will provide an immediate check on the result of the code, which you may find useful for checking your results.
Combine all of these into a single PDF that is submitted to Canvas by the due date on the Canvas link. In addition, submit all created .m files and .txt files.