Aqua Phoenix
     >>  Lectures >>  Matlab 1  
 

Navigator
   
 
       
   

1.2 Assignment - Lecture 1

For this assignment, you will familiarize yourself with the Matlab interface and basic scalar, vector, and matrix operations in Matlab. For all parts of this assignment, follow the instructions carefully, and make sure that you understand each step.

Use vector and matrix operations where necessary. This includes arithmetic and indexing operations. For example, when asked to divide one vector by another, do it is not permitted to perform this operration explicitely on each pair of numberrs - you should use vector operations instead.

1.2.1 Part A

  1. Define a vector, a, with the following set of numbers: 6, 7, 7, 7, 4, 7, 7, 7, 7, 4
  2. Define a vector, b, with the following set of numbers: 7, 1, 5, 5, 0, 1, 6, 6, 1, 0
  3. Define a vector, c, with the following set of numbers: 1, 1, 0, 0, 0, 0, 1, 0, 1, 1
  4. Compute the square of elements from vector a, and place the result in variable d.
  5. Add vector b to vector d, and place the result in variable e.
  6. Multiply the elements from vector e by the scalar 2, and place the result in variable f.
  7. Add vector c to vector f, and place the result in variable g.
  8. Pass variable g to function char() as a parameter. The result will be the final output from this step.

1.2.2 Part B

  1. Define a matrix, m, with the following rows, in order
    • Row 1: 116, 32, 97, 103
    • Row 2: 67, 82, 65, 80
    • Row 3: 82, 105, 103, 104
    • Row 4: 97, 105, 110, 33
  2. Extract the following rows and place them into a vector, n, in order: Row 3, Row 1, Row 4
  3. Pass variable n to function char() as a parameter. The result will be the final output from this step.

1.2.3 Part C

  1. Define a matrix, s, with the following rows, in order:
    • Row 1: 65, 114, 103, 104
    • Row 2: 108, 63, 115, 116
    • Row 3: 109, 63, 32, 100
    • Row 4: 111, 110, 101, 33
  2. Extract the following sets and place them into a vector, t, in order:
    • Column 1 transposed
    • Columns 3 and 4 from Row 2
    • Columns 3 and 4 from Row 3
    • Row 4
  3. Pass variable t to function char() as a parameter. The result will be the final output from this step.

1.2.4 Part D

  1. Define a matrix, u, with the following columns, in order:
    • Column 1: 32, 84, 108
    • Column 2: 33, 104, 115
    • Column 3: 39, 97, 116
  2. Extract the following sets or cells and place them into a vector, v, in order:
    • Row 2
    • Cell at Row 3, Column 3
    • Cell at Column 3, Row 1
    • Cell at Row 3, Column 2
    • Cell at Column = Row = 1
    • Cell at Column 3, Row 2
    • Cell at Column 1, Row 3
    • Cell at Row 3, Column 1
    • Cell at Row 1, Column 2
  3. Pass variable v to function char() as a parameter. The result will be the final output from this step.