Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Needs to be in a Matlab m file Submit this homework in a single m-file. The m-file should be named as your initials and then
Needs to be in a Matlab m file
Submit this homework in a single m-file. The m-file should be named as your initials and then underscore hw3, so for example my assignment would be "ar_hw3.m Use comments to distinguish between the various parts of the problem. d = 50 cm A solid metal cylinder is subjected to a load, as shown above. The maximum possible stress that the cylinder can sustain before mechanical failure is 75 Pa (75 N/m2). Note, d=50 cm is the cylinder diameter. 1. What is the algebraic solution for the limiting load in N that the cylinder can support? In your code, calculate this value algebraically and assign it to a variable. Output this limiting load to the workspace. 2. Generate 1000 random force values uniformly distributed between 0 N and 30 N, and then determine the percentage of times that the cylinder will fail. Output this percentage to the workspace. (Hint: use ('rng shuffle') before calculating the random forces] 3. Time your code using the 'tic' and 'toc' functions. Bonus points will be awarded for the fastest running codes. Put the "tic" at the beginning of part 2, and the toc at the end after the percentage has been output to the workspace. *HINT: To maximize efficiency, try to avoid using a for loop* *HINT: To maximize efficiency, try to avoid using a for loop* 4. Of your 1000 random forces, determine the maximum force for which the cylinder will not fail (maximum safe force). Of your 1000 random forces, determine the minimum force for which the cylinder will fail (minimum unsafe force). Output both values to the workspace. How do these values compare to your answer for question 1? (Make this comparison in a comment, no code is necessary.) 5. Repeat steps 2-4, but using 5000 random values. Once again output the relevant results to the workspace. How much longer does this code take to run relative to part 4? (Make this comparison in a comment.) 6. Repeat steps 1-4 if the diameter of the cylinder is halved. Submit this homework in a single m-file. The m-file should be named as your initials and then underscore hw3, so for example my assignment would be "ar_hw3.m Use comments to distinguish between the various parts of the problem. d = 50 cm A solid metal cylinder is subjected to a load, as shown above. The maximum possible stress that the cylinder can sustain before mechanical failure is 75 Pa (75 N/m2). Note, d=50 cm is the cylinder diameter. 1. What is the algebraic solution for the limiting load in N that the cylinder can support? In your code, calculate this value algebraically and assign it to a variable. Output this limiting load to the workspace. 2. Generate 1000 random force values uniformly distributed between 0 N and 30 N, and then determine the percentage of times that the cylinder will fail. Output this percentage to the workspace. (Hint: use ('rng shuffle') before calculating the random forces] 3. Time your code using the 'tic' and 'toc' functions. Bonus points will be awarded for the fastest running codes. Put the "tic" at the beginning of part 2, and the toc at the end after the percentage has been output to the workspace. *HINT: To maximize efficiency, try to avoid using a for loop* *HINT: To maximize efficiency, try to avoid using a for loop* 4. Of your 1000 random forces, determine the maximum force for which the cylinder will not fail (maximum safe force). Of your 1000 random forces, determine the minimum force for which the cylinder will fail (minimum unsafe force). Output both values to the workspace. How do these values compare to your answer for question 1? (Make this comparison in a comment, no code is necessary.) 5. Repeat steps 2-4, but using 5000 random values. Once again output the relevant results to the workspace. How much longer does this code take to run relative to part 4? (Make this comparison in a comment.) 6. Repeat steps 1-4 if the diameter of the cylinder is halvedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started