Write a script that calculates and displays the scalar product of two vectors: [1 2 ... n] and [n n-1 ... 1]. Use the first two digits of SUID as your value of n.
Answer.
n = 28; u = 1:n; v = n:-1:1; disp(u*v')
Explanation. Recall from Section 1.3 that
a:h:b means a regularly spaced vector whose entries start with a, and then change by amount h until reaching b. When h is omitted, it is understood to be 1. So, this code makes u equal to [1 2 ... 28] and v equal to [28 27 ... 1]. Both are row vectors. Transposing the second vector into a column is necessary for their product to make sense, as noted in Section 1.4. Note that each of these lines ends with a semicolon, which prevents the intermediate results from being displayed on screen. Then disp displays the final result.
