Professional Documents
Culture Documents
Lab 1
Lab 1
Lab 2
APPLIED LINEAR ALGEBRA FOR IT - 501032
1 Exercises
Exercise 1: Write a command
to create vectors and get
the number of elements in each vector. x =
1 3 5 2 9 and y = −1 3 15 27 29
Exercise 2: Write a command to create the following vectors with n elements (user-defined variable)
(a) b = 12 14 16 18 20 22 24 26 28 30 32 ...
(b) c = 31 33 35 37 39 41 43 45 47 49 51 ...
(c) x = ... −5 −4 −3 −2 −1 0 1 2 3 4 5 ...
(d) y = ... 5 4 3 2 1 0 −1 −2 −3 −4 −5 ...
(e) z = 10 8 6 4 2 0 −2 −4
1 1 1 1 1 1 1
(f) w = 1 ...
2 4 8 16 32 64 128
1 1 1 1 1 1
(g) d = 1 1 ...
2 3 5 8 13 21
1 1 1 1 1 1 1 1 1
(h) e = ...
2 3 5 7 11 13 17 19 23
(i) a = 1 3 6 10 15 21 28 36 ...
1 1 1 1
(j) n = ...
2 5 10 17
1 2 3 4
(k) p = 0 ...
2 3 4 5
(l) Create o vector that contains the characters from ’a’ to ’z’
(m) Create s vector that contains the characters 0 A0 0 D0 0 G0 0 J 0 ...
Exercise 3: Write a command to create the following vector by logarithmic spacing method
x = 101 102 103 104 105 ... 10n
Exercise 4: Let two vectors x = 1 2 3 and y = 98 12 33 . Write a command to create a
vector z = 1 2 3 98 12 33 from x and y.
Exercise5: Let twovectors x = 1 2 3 and y = 4 5 6 . Write a command to create a vector
1 2 3
z=
4 5 6
Anh H. Vo - vohoanganh@tdtu.edu.vn 1
Ton Duc Thang University
Faculty of Information Technology
Exercise 6: Let x = 0 2 4 6 8 10 12 14 16 18 20 . Write a command to perform the
following:
Anh H. Vo - vohoanganh@tdtu.edu.vn 2