M1_Sequential Algorithms and Programs

pdf

School

University of California, Los Angeles *

*We aren’t endorsed by this school

Course

331

Subject

Industrial Engineering

Date

Dec 6, 2023

Type

pdf

Pages

4

Uploaded by EarlMetalLion28

Report
Assignment M1_ MatLab Sequential Algorithms and Programs (Individual, 40 points) Overall Purpose This assignment will help you to learn how to write and run simple MatLab programs using algorithms. An algorithm is a set of steps for solving a problem, and it appears in a computer program as a set of comment statements for each major step. Description Solve each of the following three problems by writing and running MatLab scripts, and reporting your results. Please include the following for each problem: 1. A brief statement explaining the problem (1-2 sentences) 2. A list of the major steps that describe how you will solve the problem ( this is the algorithm ). 3. The listing of your code (copy and paste your script into your word processor with the source formatting) 4. A screen capture of a sample run with the requested values, showing the command window and the workspace. These must be legible. 5. Please create one pdf file to include all of the information from #1 through #4 for all three problems. 6. Hints for more efficient programming: a. Write the algorithm first as a set of comment statements in MatLab, then insert the lines of code to perform the step indicated in the comment line(s). b. Choose descriptive variable names. Names like Course1 and JovianDay are easier for others to understand than x, y, z, etc. c. Use ‘disp’ on one line to describe units and on a second line to output values for a variable as an easy way to communicate your results. d. The “Snipping Tool” or “Snip & Sketch” (use your Windows search bar to find it) are good ways to create readable screenshots. Problem 1: Time Conversion As part of your astronomy class, you are required to track the movement of the Great Red Spot in the atmosphere of Jupiter. Since the experiment is following activity in Jupiter, the measurements are taken in Jupiter time. In order to publish your findings, you need the plots to reference time in either Earth days or hours. You know that one day in Jupiter is equivalent to 9.93 Earth hours (9 hrs. 56 mins). Since you are working with a large amount of data, you make a MATLAB program to convert your measurements from Jupiter days to Earth days or hours. Your program should do the following: Request a user input for Jupiter days Convert the time from Jupiter days to Earth days Calculate the time from Earth days to Earth hours Output the results in the command window, along with descriptions so that the user knows what they are seeing Run the program for a sample run with a measurement of 14.2 Jupiter days.
Problem 2: GPA Calculator You want to calculate your grade point average (GPA). Create a MATLAB program that will input credit hours and grades for each course and calculate your GPA for that semester. Assume that you will always have four courses each semester and that no + or - grades exist. Your program should do the following: Request that the user input the number of credit hours for a first course, and then the number of grade points earned for that course (A = 4, B = 3, etc.). Hint: input the numeric value for each grade, not the letter grade itself. Repeat this process for the second, third, and fourth class. Calculate your GPA, using the following formula: 𝐺𝑃𝐴 ൌ ∑ሺ𝐶𝑜𝑢𝑟𝑠𝑒𝐺𝑟𝑎𝑑𝑒 ∗ 𝐶𝑜𝑢𝑟𝑠𝑒𝐶𝑟𝑒𝑑𝑖𝑡𝑠ሻ ∑ሺ𝐶𝑜𝑢𝑟𝑠𝑒𝐶𝑟𝑒𝑑𝑖𝑡𝑠ሻ Output your semester GPA with a suitable text label Create a sample run for a student who has received the following grades: Class Credits Grade Math 3 A Chemistry 4 B Phycology 3 C Chem Lab 2 A Problem 3: Shape Change Calculator You get a job at the school’s machine shop to help with college expenses. Here, you assist professors with their research projects by machining the parts they need. Your first assignment is to help a materials engineering professor who is studying the molecular structure of a particular metal. They bring you a square pyramid of the metal and tell you that they need as many 2in x 2in x 2in cubes out of it as possible. They also need to know the total surface areas of the cubes that will be available for their experiments. Create a MATLAB program that will take a user-entered pyramid width and height and outputs the maximum number of cubes, as well as the total surface area of the cubes. (Assume that the leftover material can be melted down to make additional cubes.) Your program should do the following: Request a user input for the pyramid width and height, both in inches Calculate the volume of the square pyramid and volume of a cube Calculate how many cubes you could obtain from one pyramid Output the number of cubes and their surface area. Don’t forget to add units. Create a sample run for a pyramid with an edge of 6 inches and a height of 12 inches. Deliverables for this assignment: 1. .m files for each problem with appropriate file names (3 m-files in total) 2. File name convention for .m files: YourPID _M1_P1.m, YourPID _M1_P2.m, YourPID _M1_P3.m (Example: nvantyne_M1_P1.m)
3. A single .pdf file with an appropriate file name, containing Standard header for individual assignments For each problem A brief statement explaining the problem (1-2 sentences) The algorithm, i.e., a list of steps for solving the problem The listing of your code (copy and paste your script into your word processor with the source formatting) A screen capture of a sample run with the requested values, showing the command window and workspace. These must be legible. File naming convention: YourPID_M1.pdf Primary Grading Criteria (see the rubric for specific items) Program functionality Accuracy of solutions Good programming practices Readability and inclusion of requested elements Rubric The rubric for this assignment is given below. Rubric for Assignment M1_Sequential Algorithms and Programs (Individual, 36 points) Points Problem 1: Time Conversion Summary All required elements are present, and the summary is easy to read and understand 2 A few elements are missing 1.8 Many elements are missing 1.4 Neither the summary nor the code file were submitted 0 Correct Code was Submitted Program works as intended with no problems 8 Program works but minor errors reduce utility or affect results 7.2 Some minor functional issues prevent the program from running properly, or requested elements are missing 6.4 Major changes are required for the program to run 5.6 All or most of the program is missing 0 Coding Practice - Thorough Commenting Comments are sufficient to understand what the program is doing 1 A few comments are missing that are necessary to understand what the program is doing. 0.9 A large number of necessary comments are missing. 0.7 There are no comments in the program. 0 Coding Practice – Variable Names Descriptive names for all variables 1 A few variable names are not sufficiently descriptive, e.g., x, y, etc. 0.9 All or most variable names are not sufficiently descriptive 0.7 Problem 2: GPA Calculator
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Summary All required elements are present, and the summary is easy to read and understand 2 A few elements are missing 1.8 Many elements are missing 1.4 Neither the summary nor the code file were submitted 0 Correct Code was Submitted Program works as intended with no problems 8 Program works but minor errors reduce utility or affect results 7.2 Some minor functional issues prevent the program from running properly, or requested elements are missing 6.4 Major changes are required for the program to run 5.6 All or most of the program is missing 0 Coding Practice - Thorough Commenting Comments are sufficient to understand what the program is doing 1 A few comments are missing that are necessary to understand what the program is doing. 0.9 A large number of necessary comments are missing. 0.7 There are no comments in the program. 0 Coding Practice – Variable Names Descriptive names for all variables 1 A few variable names are not sufficiently descriptive, e.g., x, y, etc. 0.9 All or most variable names are not sufficiently descriptive 0.7 Problem 3: Shape Change Calculator Summary All required elements are present, and the summary is easy to read and understand 2 A few elements are missing 1.8 Many elements are missing 1.4 Neither the summary nor the code file were submitted 0 Correct Code was Submitted Program works as intended with no problems 8 Program works but minor errors reduce utility or affect results 7.2 Some minor functional issues prevent the program from running properly, or requested elements are missing 6.4 Major changes are required for the program to run 5.6 All or most of the program is missing 0 Coding Practice - Thorough Commenting Comments are sufficient to understand what the program is doing 1 A few comments are missing that are necessary to understand what the program is doing. 0.9 A large number of necessary comments are missing. 0.7 There are no comments in the program. 0 Coding Practice – Variable Names Descriptive names for all variables 1 A few variable names are not sufficiently descriptive, e.g., x, y, etc. 0.9 All or most variable names are not sufficiently descriptive 0.7 Total Points Possible: 36