辅导ENGR 131、MATLAB编程设计调试、Programming讲解、MATLAB语言辅导 解析Haskell程序|讲解Java程序

- 首页 >> Python编程
ENGR 131: Elementary Computer Programming
ENGR 131 20F-IN-030-05 (Lab 5 Instructions) 9/24/2020 Page 1 of 3
Lab Exercise #5
INSTRUCTIONS
Complete the exercises below and upload them to Canvas as a single MATLAB script file using the naming
convention “ENGR131_20S_Lab##_abc123.m”, replacing abc123 with your Case ID, and ## with the two-digit
lab number.
For example, if Dr. Williams were submitting Lab 5 it would be ENGR131_20F_Lab05_mrw8.m
For your script, please perform the following:
1. Separate each question into separate, runnable sections using the “%%” comment notation.
2. You may use the code and notes from class, the textbook, MATLAB’s documentation, and anything you
find using Google to solve these problems.
3. Use comments as appropriate to indicate your thoughts and how your code works (or is supposed to work).
This is 5 points (10%) of your grade.
QUESTIONS
There are 2 questions for this lab.
1. SOLVING SYSTEMS OF EQUATIONS (5 PTS)
Given the system of equations below, solve for the value of each letter using the numeric technique (not symbolic).
A + A + B + B = 63
A + B + C + D = 40
A + E + E + B = 15
A + C + C + D = 26
E + B + C + D = 33
2. COMPUTING VOLUMES (40 PTS)
A particular conical red cup is often found at many social gatherings in college. The dimensions of this cup can
be found in Fig. 1. Based on these dimensions, use Matlab to determine the locations at which you would place
markings for 2.75, 6, and 16 oz. of fluid. Also compute the error in your computed volume from these three target
volumes.
ENGR 131 20F-IN-030-05 (Lab 5 Instructions) 9/24/2020 Page 2 of 3
To recreate something similar to Fig. 1b and c, perform the following:
a. Create a function to compute the radius of the cross section of the cup for an input x vector. Keep in mind
that Fig 1a lists diameters and you want radii (3 pts)
b. Create a function that will plot your results based on input arguments of your step size (outer) loop and
your computed heights.
a. This function should plot
i. the overall profile of the cup (2 pts)
ii. The marking locations based on step size = 0.01 in with closed marker faces (3 pts)
iii. The marking locations based on step size = 0.2 in with open marker faces (3 pts)
b. It should include appropriate labels and titles (3 pts)
c. Adjust the axis limits so they’re even and the cup profile looks right (1 pts).
d. Hint: You’ll need both the x and y values for the markers. Once you record your computed target
height (Part d below) you can always call the function you created in Part a to get the y for plotting.
Fig. 1. Dimensions of popular party cup (a), profile of cup
with indications of volume measurements for 2.75,64, and
16 oz (b). Closed markers indicate step size of 0.01 in, open
are for step size = 0.2 in. Volume errors of computed
marking locations relative to target volumes by step size (c).
Cup Profile With Markings for 2.75, 6, and 16 oz
2.75 6 16 2.75 6 16
Volume (oz) by step size (0.01 & 0.2 in)
Error as a function of step size and target volume
ENGR 131 20F-IN-030-05 (Lab 5 Instructions) 9/24/2020 Page 3 of 3
c. Create a matrix of target volumes. Remember to convert the units given into in3 (1 pts)
d. Since you’re iterating over 2 step sizes, and determining three currently unknown values, create a nested
loop structure using the following loops:
a. An outer for loop that determines step size (0.01 or 0.2) (4 pts)
b. An inner for loop that determines the target volume to test (4 pts)
c. An inner inner while loop that computes the volume of the cup by integrating the volume of the
revolved solid for an incrementally increasing height. You are welcome to use either the Riemann
or trapz method of integration. This loop should exit once the height that produces the target
volume is determined (10 pts).
i. Hints:
• Use a counter in the while loop that increases by 1 every time through the loop
• x = [0:dx:counter*dx]
• Store your final computed target heights OUTSIDE of the while loop, but inside the inner
for loop in a 2x3 matrix where the row is for each step size and the columns are for each
the target volume
• Record the error (Computed volume / target volume) similarly
e. Plot the errors in volume as a bar plot with appropriate title and labels (6 pts)
a. Hint: use set(gca,’XtickLabel’,{ {'','2.75','6','16','','','2.75','6','16'}) to get the x labels correct
Revision Description Date
A Original Document 9/24/2020

站长地图