Exercise 2: Basic Matrices Syntax and Manipulations

The following exercises are meant to be answered by a single MATLAB command. The command may be involved (i.e., it may use a number of parentheses or calls to functions) but can, in essence, be solved by the execution of a single command. If the command is too complicated, feel free to break it up over two or more lines.



1. Given the matrix A = [2 9 6 8 ; 3 2 7 5 ; 8 2 3 5], provide the commands needed to


  a. assign the element in the first row and second column of A called y

  b. assign the elements of four corners to 2-by-2 matrix called y

  c. assign the first row of A to a vector called y

  d. assign the even-numbered columns of A to an matrix called y

  e. assign the odd-numbered rows of A to an matrix called y

  f. assign the last 3 columns of A to an matrix called y

  g. transpose A into a 4-by-3 matrix

  h. change size A into a 4-by-3 matrix, using the command "reshape" may be helpful here.



2. Create the 3-by-3 matrix M with integers number between 0 and 50 (include 0 and 50) randomly.




3. Given the matrix A = randn(4), provide the command that will


  a. compute the determinant of A

  b. compute the mean of all elements of A

  c. compute the product over the rows of A

  d. compute the sum over the columns of A

  e. compute the inverse of A

  f. compute the standard error of each column of A (NB. the standard error is defined as the standard deviation divided by the square root of the number of elements used to compute the mean.)



4. The mechanical work W done in using a force F to push a block through a distance D is W = FD. The following table gives data on the amount of force used to push a block through the given distance over five segments of a certain path. The force varies because of the differing friction properties of the surface.
























Use Matlab to find

a) the work done on each segment of the path.

b) the total work done over the entire path.


5. Solve the following for y.


6. Given B, C, and D:

Find A where C(A + B) = D.



Solving linear equations


7. Six people, Fred, Grace, Harry, Irene, Jerry, and Kim, each have a debit card.

  q          The total money owed on all six credit card balances is $456.

  q          Fred owes twice as much money as Irene.

  q          Jerry and Kim's total balances equal Grace's.

  q          Irene and Jerry's total balances equal the total of Grace and Harry's.

  q          If you subtract Grace's balance from Harry's, the total is twice Irene's.

  q          The sum of Jerry and Grace's balances are greater than Harry's by $115.


  a. Write the linear set of equations.

  b. Write all of the MATLAB code needed to solve the problem.

  c. Who owes money and how much? Who has credit and how much?