ENGR 126 Exam 3 Solution Spring 2008

# ENGR 126 Exam 3 Solution Spring 2008 - or func_neg =...

This preview shows pages 1–2. Sign up to view the full content.

Exam 3 Answer Sheet ENGR 126 April 15, 2008 Name: Email: Seat: Div: Team #. ( Don't forget to answer the questions on the back. ) Problem #1 (8 points) Answer 6 64 Problem #2 (8 points) Answer x = 0; x = x+1; disp([x y]) disp('All done.') or lines 1,4,6,8 or all lines with "x" and "disp" Problem #3 (12 points) Answer tol = 0.01; err = 1000; y = 15; while abs(err) > tol y_old = y; y = my_func(y_old); err = y - y_old; end disp(y) disp(err) Problem #4 (16 points) (a) while…end for…end (b) while…end for…end (c) while…end for…end (d) while…end for…end Problem #5 (12 points) Answer Change the scale of the x-axis to a logarithmic scale or transform the data by computing log(x), then plot y vs. log(x) using a linear x-scale or Semilogx Problem #6 power function Problem #7 (8 points) Answer m = 2 b = 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
( Don't forget to answer the questions on the front. ) Problem #8 (12 points) Solution: >> func_1='sin(x/5)^2*cos(x-1)' >> func_neg='-sin(x/5)^2*cos(x-1)' or func_neg = ['-' func_1]
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: or func_neg = ['-' func_1] >> xmax=fminbnd(func_neg,5,10) >> x=xmax or x = fminbnd(func_neg,5,10) >> max_amp=eval(func_1) Problem #9 (20 points) % UPS.m – A program to calculate the maximum volume that can be shipped via UPS % given the largest dimension of a package. % Input max_size = 165; % UPS constrains max length + girth 165 inches % Calculation for index = 1:1:8 % could use length = 35:10:105, but must compute consecutive index length(index) = 35 + 10*(index-1); % check lengths from 35-105 inches side(index) = (max_size – length(index))/4; % assuming square cross-section volume(index) = length(index)*side(index)^2; end index = 1; %Alternate solution for length = 35:10:105 side(index) = (max_size – length(index))/4; volume(index) = length(index)*side(index)^2; index = index + 1; end % Output plot(length,volume) title('Maximum UPS package volumes') ylabel('Package volume (cu in)') xlabel('Length of package (in)')...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern