Monday, December 14, 2015

day 9 (lecture)

This lecture had only two unique exercises. The repeated ones can be found in other posts


#1
a = [12 17 3 6] 
b = [5, 8, 3 1, 2, 3 2, 4, 6] 
c = [22 17 4] 


1) Assign to the variable x1 the value in the second column of matrix a. 
2) Assign to the variable x2 the third column of matrix b. 
3) Assign to the variable x3 the values in matrix b along the diagonal. 
4) Assign to variable x4 the first three value in matrix a as the first row and all the values in matrix b        as the second through fourth row. 
5) Assign to variable x5 the values in matrix c as the first column, the values in matrix b as columns        two through 4, and the values in matrix as the final column 
6) Convert matrix b to a column vector name x6 



#2

1) Create a 3 X 3 matrix of zeros
2) Create a 5 X 3 matrix of ones
3) Create a 4 X 6 matrix in which all the elements have a value of pi.
4) Use the diag function to create a matrix whose diagonal has value of 1, 2, 3.
5) Create a 10 X 10 magic matrix.
    a. Extract the diagonal from this matrix.
    b. Extract the diagonal that runs from lower left to upper right from this matrix.
    c. Confirm that the sums of the rows, columns, and diagonals are all the same.
6) Extract a 3 X 3 matrix from the upper left hand corner of the 10 X 10 matrix you just created. Is this also a magic matrix?




*Everything that has "ans" are all the sums of the magic square, the answer to the last question is no

No comments:

Post a Comment