{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

I- Computer Questions- Solutions and RubricExam 1

# I- Computer Questions- Solutions and RubricExam 1 -...

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

Computer Question 1: Calculating the Value of a Function f(x) = 4e x+2 for -6 <= x < -2 x 2 for -2 <= x < 2 (x+62) 1/3 for 2 <= x <= 6 Write Matlab code that asks the user to enter x, and then displays the value of f(x) for that x. If the user enters a value that is outside of the domain of this function (i.e. x is not between -6 and 6), your code should instead display “Error” x = input( 'Enter x ' ); if (x<-6 | x>6) disp( 'Error' ) elseif (x<-2) f = 4*exp(x+2) elseif (x<2) f = x^2 else f = (x+62)^(1/3) end -6 if they have minor syntax errors that cause their code not to run (they had the computer to check answers) -9 if there are major syntax errors -10 if some of their conditions are wrong, or some of their calculations are wong -12 if there are major flaws with the logic of their program, but seem to understand how if and input work -14 if they have no idea Computer Question 2: Sum of Composites Run the following commands, which create a 100 element matrix B : rand( 'state' , 4 ) ; B = round( 120*rand(10,10) - 10 ); Write Matlab code that calculates the sum of all of the numbers in B

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

View Full Document
This is the end of the preview. Sign up to access the rest of the 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