Matlab: Linear Algebra ----------------------- Practical Exercises ------------------- Session 1 (Basic Matrix Use) ---------------------------- 1.1 Create a matrix M with the following values: 1.1 -5.0 4.7 -4.0 4.7 -22.3 -4.1 2.3 19.2 Create a row vector R with the following values: 1.6 -16.5 10.5 Create a column vector C with the following values: 0.7 -5.1 -4.8 Print the element in the second row and third column of M. Print the rank (number of dimensions) and the individual dimensions of M, R and C. 1.2 Calculate R times M times C, using matrix multiplication. Calculate C times M times R, transposing the vectors as necessary. [ Note that the values will be different. ] Calculate C times (M transpose) times R, transposing the vectors as necessary. [ Note that we have the first value again. ] Calculate C times M times R, without transposing anything. 1.3 Set A to be the 7x7 Hilbert matrix. Set B to be the middle three rows (i.e. rows 3-5) and last four columns (i.e. columns 4-7) of A. Set D to be the second column of B and E to be the second row of B (note B and not A). Set F to be the second column of B as a row vector. Print the the individual dimensions of A, B, D and E. 1.4 Set V to be a row vector of length 5, with all elements zero, using a constructor. Set W to be a 5x5 matrix with all elements two, except that the diagonals are five, using constructors. Set W to be a 5x5 Hilbert matrix, multiplied by the sum of a 5x5 unit diagonal matrix and a 5x5 inverse Hilbert matrix. [ Note that this is a convoluted way of adding one to the diagonal of a Hilbert matrix ] Set X to be the 5th power of the 5x5 Hilbert matrix, with all elements reduced by two (i.e. subtract two off each). Print the diagonal vector of X, and then set Y to be a 5x5 matrix with X as the diagonal and zeroes elsewhere. 1.5 Set R to be a 5x5 matrix with each element the square of the corresponding element of the Hilbert matrix. Set S to be a 7x7 matrix with element i,j having the value cos(pi*(i+j-2)/6). [Clue: use elementwise operations on the Hilbert matrix ] The matrix M has the following values (recreate it if necessary): 1.1 -5.0 4.7 -4.0 4.7 -22.3 -4.1 2.3 19.2 Print the maximum value in each row and the minimum value in each column, using the max and min functions. Print the product of the values in each row and the sum of the values in each column, using the prod and sum functions. 1.6 Set up a row vector A with values 1, 2, ..., 6 and a column vector B with values 1, 2, ..., 4. Print the dot products A.A and A.B, using the dot function Print the dot products A.A and A.B, using matrix multiplication and transposition. Set up a row vector A with values 1, 2, ..., 6 using linspace. Using A, create a 6x6 matrix B with element i,j having the value (1/i*j). [Clue: program the outer product yourself ]