{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

H- Computer QuestionsExam 2

H- Computer QuestionsExam 2 - Write a function called...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Question 1: Write code that simulates a TV remote control. Use the menu command to display the numbers 3 through 9 as separate buttons. (Note that they don’t have to be in the same layout as on a remote control). Have a final menu item: “Turn TV off” The user will click a channel number (3 through 9). Then, keep repeating this process of displaying the menu and clicking a channel number until “Turn TV off” is clicked. At that point, use fprintf to display 1) the last channel the TV was on before it was shut off, and 2) How many times the channel was changed. Computer Question 2: Write code that animates the following equation as an ‘X’ floating around the screen. Let t run from 0 to 10: x(t) = (t-5) 2 y(t) = (10-t)cos(t) Use x running from 0 to 25 and y running from -10 to 10 as your axes. The animation should start on the right of the screen, come to the left and make a loop, and then go back to the right. Computer Question 3:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Write a function called overallmax that accepts a matrix as its input argument, and returns a vector containing the maximum value in that matrix. (You just need to return the maximum value, not the location). Use a loop to do this; you cannot use the max function. Computer Question 4: Assume the coefficients of a polynomial are stored as vectors. For example y(x) = x^2+2 is stored as [1 0 2], from highest degree coefficient to least. Write a function called my_poly_eval that accepts two input arguments: a polynomial whose coefficients are stored as a vector, and an x value. You function should calculate the value of the polynomial at that x value. For example, running my_poly_eval( [1 0 2] , 3) yields 11. Hint: Write a for loop that goes through each of the coefficients, and multiplies that coefficient by the appropriate power of x. Note that as you more from left to right in the vector, the powers get smaller ....
View Full Document

{[ snackBarMessage ]}