Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DO in matlab pls Instructions: Complete Problem 1 and Problem 2 below. Create a single script (.m file) to complete this assignment. Unless directed otherwise,

image text in transcribedimage text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed DO in matlab pls

Instructions: Complete Problem 1 and Problem 2 below. Create a single script (.m file) to complete this assignment. Unless directed otherwise, use meaningful variable names for each variable; do not use the default variable ans to store your results. For this assignment suppress your output with semi-colons (;). Each problem (i.e. Problem 1 and Problem 2) should be in a separate cell, using the cell mode feature of MATLAB; the subparts should all be contained in the same cell as the parent problem. Please remember to follow the Programming Style Convention on Canvas. When complete, please submit your code to the dropbox on Canvas; the grader will run it to view your output. Name your file like this: username_assignment7.m (example: bjs5332_assignment7.m). Your submission must be a single .m file. Problems: 1. You are working on a manufacturing process at a summer internship. For a specific manufacturing process, a given part is produced 25 units at a time. The machine outputs a CSV file with a measurement of how close each part in a batch was to the required specification; positive numbers indicate that the unit was X c.m. longer than the specification, while negative numbers indicate that the unit was X c.m. shorter than the required specification. If any part in a batch of 25 parts is 0.5 cm (or more) longer, or 0.5 cm (or more) shorter, than the required specification, then the entire batch of 25 parts must be rejected and the operator notified to check the manufacturing machinery. If all of the parts are acceptable, then the operator should be notified that the batch was acceptable. Read about the readmatrix( ) command in the MATLAB help documentation, then use it to programmatically load in the data from this data file. (There are a lot of bells-and-whistles available with readmatrix(), but the first syntax example noted in the help documentation is all that you need here.) Then, use a while loop to loop through each individual data point (one data point per iteration) to check to see if the part met the manufacturing specifications. If it did, print a statement to the screen indicating that. If it did not, print a statement to the Command Window indicating that, and terminate your part-checking process. After you are done with the checking process, print a message to the Command Window indicating the outcome from that batch of parts. Your code should be able to emulate the sample runs below, even if the provided CSV file's data only meets one of these two sample run conditions. Observe that there is space for a two digit numeric output; your code should preserve that spacing. Sample Run #1: All parts were satisfactory. Part No. 1 was made to specification. Part No. 2 was made to specification. Part No. 3 was made to specification. Part No. 4 was made to specification. Part No. 5 was made to specification. Part No. 6 was made to specification. Part No. 7 was made to specification. Part No. 8 was made to specification. Part No. 9 was made to specification. Part No. 10 was made to specification. Part No. 11 was made to specification. Part No. 12 was made to specification. Part No. 13 was made to specification. Part No. 14 was made to specification. Part No. 15 was made to specification. Part No. 16 was made to specification. Part No. 17 was made to specification. Part No. 18 was made to specification. Part No. 19 was made to specification. Part No. 20 was made to specification. Part No. 21 was made to specification. Part No. 22 was made to specification. Part No. 23 was made to specification. Part No. 24 was made to specification. Part No. 25 was made to specification. There were no issues with this batch of parts. Sample Run #2: The fourth part did not meet the required specification. Part No. Part No. 1 was made to specification. 2 was made to specification. 3 was made to specification. 4 was NOT made to specification. Part No. Part No. The manufacturing process needs adjusted. Hints: 1. Consider carefully your termination criteria. Consider using a "flag" to signal to the loop that the termination criteria was met. A flag is a variable whose value is used to control some process (such as a loop). If a bad part is encountered, change the value of your flag so that it indicates to your repetition structure that it should stop. However, if there was no problem encountered with your batch, your repetition structure should also stop after all 25 data points are processed. 2. There is a very simple way to control the output to ensure that there is room for a two digit number; think about the width and precision information from Slide 19 of Lecture 09. 2. Create a program to repeatedly prompt the user for two numbers. The program should print the sum of the two numbers on every iteration, and then the program should add the sum from the current iteration to a running sum that accumulates across all of the iterations. If the user enters two numbers whose sums are either 0 or 7, complete that iteration then terminate the repetition process. Report to the user that the termination criteria was met, then print the running sum to the user. Emulate the sample runs below, including the behavior of printing integers like integers and printing numbers with a decimal with only the number of decimal places needed; be sure to automate that printing process. Sample Run #1: Enter the first number: 3 Enter the second number: 5 The sum of the inputs 3 and 5 was 8. Enter the first number: 3 Ente r: 4 The sum of the inputs 3 and 4 was 7. Termination criteria reached. The running sum of the numbers entered was 15. Goodbye! Sample Run #2: Enter the first number: 1 Enter the second number: -3 The sum of the inputs 1 and -3 was -2. Enter the first number: 1 Enter the second number: 7 The sum of the inputs 1 and 7 was 8. Enter the first number: -4 Enter the second number: 4 The sum of the inputs -4 and 4 was 0. Termination criteria reached. The running sum of the numbers entered was 6. Goodbye! Sample Run #3: Enter the first number: -2.3 Enter the second number: 3.1 The sum of the inputs -2.3 and 3.1 was 0.8. Enter the first number: 0 Enter the second number: 0 The sum of the inputs 0 and 0 was 0. Termination criteria reached. The running sum of the numbers entered was 0.8. Goodbye! Hints: 1. A do while loop-like process may be helpful here. 2. There is a very helpful typefield available to help you with ensuring that the printing is as "short" as possible. We have not used this typefield much so far, so reference Slide 17 of Lecture 09

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Icdt 88 2nd International Conference On Database Theory Bruges Belgium August 31 September 2 1988 Proceedings Lncs 326

Authors: Marc Gyssens ,Jan Paredaens ,Dirk Van Gucht

1st Edition

3540501711, 978-3540501718

More Books

Students also viewed these Databases questions