{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


14440127-_20Recitation_203_20Problems-_20Solutions -...

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

View Full Document Right Arrow Icon
14:440:127 Introduction to Computers for Engineers Recitation 3- Problems for students to attempt 1) Create a row vector containing the even numbers 2 through 18, a column vector containing 1,5,9,…,25,29, and a 3*3 matrix A. Then, transpose A and save that as B . Finally, calculate the element by element (dot) multiplication of A and B . rv = 2:2:18; cv = 1:4:29 A = [ 1 5 2; 34 23 1]; B = A’; A .* B 2) Write a program that ask the user to input the value of ‘How many days do you want rent this DVD?’ Then, calculate how much they should be charged for this rental. The store charges $3.99 for the first day, and then $1 for each additional day. However, a week long rental is only $8. After one week, they are charged $1 for each additional day, up to a maximum fee of $50. days = input(‘How many days do you want to rent this DVD?’); if(days>=49) charge= 50; elseif(days>=7) charge = days+1; elseif(days>1) charge=days+2.99; else charge=3.99 end 3) Create a 3 x 4 matrix in which all the elements have a value of pi. (consider creating a matrix in which all of the values are 1 first, and then multiplying). Then, change the 2nd row to -pi. Finally, compute the sine of each value in the matrix. m = pi*ones(3,4); m( 2, : ) = -1 * m( 2, : ) sin(m) 4) Find the zeros of the polynomial 5x 4 - 4x 2 + 18 roots( [ 5 0 -4 0 18 ] ) 5) Use help to look up the magic function. Create a 5 x 5 magic matrix. Then: a. sort each column of the matrix m = magic(5); sort(m) b. sort each row of the matrix m = magic(5);
Background image of page 1

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

View Full Document Right Arrow Icon
sort(m’)’ c. find the maximum number in each row m = magic(5); max(m’) d. prompt the user to enter a row, and then to enter a column. Display the element in that row and column m = magic(5);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}