# Computing Data (Octave)

Matrices

1. A = [1 2; 3 4; 5 6]

B = [11 12; 13 14; 15 16]

C = [1 1; 2 2]

2. A*C

3. A .* B take each element of A to multiply by each element of B

4. A .^ 2 square each element of A

5. v = [1; 2; 3]

6. 1 ./ v element-wise reciprocal of v

7. log(v) element-wise logarithm of v
exp(v) element-wise exponential of v
abs(v) element-wise absolute value of v
-v element-wise negative value of v
v+1 element-wise addition of 1 to v

8. A = [1 2; 3 4; 5 6]

A' transpose of A

9. w = [1 15 2 0.5]

10. max (w) maximum value of w
val = 15

11. [val, ind] = max(w) maximum value of w and index where it is located
val = 15
ind = 2

12. w < 3 element-wise comparison of whether w is less than 3

13. find(w < 3) find which elements that variable w is less than 3

14. sum(w) sum of w
ans = 18.5

15. prod(w) product of w
ans = 15

16. floor(w) rounds down elements of w

17. ceil(w) rounds down elements of w

18. A = magic(3) magic square of 3 by 3

19. [r,c] = find(A >= 7) find rows and columns of A greater than or equal to 7

20. A(2,3)

21. max(A,[],1) column-wise maximum of A

22. max(A,[],2) row-wise maximum of A

23. max(max(A))

24. pinv(A) inverse of A

×