Introduction to Matlab



Introduction to Matlab

Lecture 2: Matrix Operations and Relational Operators

Exercises

1. Enter the following matrices from week 1 on your workspace

2. Remove the 3rd row from matrix D

3. Add a column of 4’s to the end of matrix A

4. Remove the last row from matrix C

5. Confirm the new number of elements in A and D match with the size or length functions

6. Create a 3-Dimensional matrix G by concatenating matrix D and F

7. Use matrix indexing to change the two zeros in matrix G to 25

8. Add 15 to every element in the first row of matrix A

9. Subtract 5 from every element of matrix B

10. Create a matrix H that is the dot product of the first 3 columns of matrix A and the first 3 columns of matrix D

11. Create a matrix J that is the dot product of matrix H with the transpose of matrix C

12. Divide every element of J by 2

13. Divide the first element of B by zero

14. Find the resultant NAN value in B and change it to a real positive number

15. Find every element of D that is greater than 20 and assign the list of index positions to the variables ‘xpos’ and ‘ypos’

16. Use ‘xpos’ and ‘ypos’ to change every element of D that is greater than 20 to be 15

17. Use relational operators to confirm that D no longer contains elements greater than 20

18. Use relational operators to find the elements of A that are greater than 10

-----------------------

F = a 3 x 4 matrix of 1’s

E =

[pic]

D =

[pic]

C =

B =

A =

[pic]

[pic]

[pic]

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download