I- Computer Questions- Solutions and RubricExam 1

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/29/2012 for the course 440 127 taught by Professor Blase during the Fall '09 term at Rutgers.

Page1 / 4

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online