B- Computer QuestionsExam 1

B- Computer QuestionsExam 1 - Now, write Matlab code that...

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

View Full Document Right Arrow Icon
Computer Question 1: Plot and Subplot Write Matlab code that displays the following four graphs next to each other (in one figure) as seen below. Let x contain 100 evenly spaced points, running from 0 to 10. Title and label both the x and y axes of your graph. a) y = x 2 b) y = x 3 c) y = (x- 5) 3 d) y = x Computer Question 2: Even Integers Write Matlab code that does the following: Ask the user to input a number. (You can assume they’ve entered a number, and not a character string). Verify that the number that they’ve entered is 1) positive 2) an integer 3) even If any of these conditions is not met, display an error message stating which condition was not met. If all 3 conditions have been met, display “Success.”
Background image of page 1

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

View Full DocumentRight Arrow Icon
Computer Question 3: Finding the 3 largest elements Run the following commands, which create a 100 element row vector b : rand( 'state' , 4 ) ; b = round( 100*rand(1,100) )
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Now, write Matlab code that calculates the 3 largest numbers (and their locations) in the vector b , and then displays the following statement using fprintf: "The largest number is 98, which is element 51. The second largest number is 96, which is element 29. The third largest number is 98, which is element 40." (In the event of a tie, the location of those elements can be switched; it doesn't matter which comes first) The same code you write to solve this problem must work, without any modifications, if you instead run the following first: rand( 'state' , 2 ) ; b = round( 100*rand(1,100) ) Computer Question 4: Plotting a surface For both x and y running from 0 to 50 (in increments of 1), display the following 3-D surface using the surf command: z = x + cos(x) + y 2 /50 Turn the grid on. Your surface should look something like this:...
View Full 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 / 2

B- Computer QuestionsExam 1 - Now, write Matlab code that...

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