3. Nested For Loop Statement: Write the following scripts using nested for loops (30 pts)
mat
5 9 1 6 1
10 6 5 5 6
7 2 2 1 1
7 3 10 7 9
9 9 8 1 9
a) Display the elements of the given matrix, mat. It should look as above.
b) Display only upper triangular elements (row index < column index) of the given matrix,
mat.
c) Calculate the sum of the lower triangular elements (row index > column index) of the
given matrix, mat.
4. Non-vectorization: This problem is the same as Problem 1 in Homework 3, but you need to
use for and if statements to solve this problem (non-vectorized code to practice for and if
statements).
The data of height, weight, and age of a group of people were collected and stored in the
vector as below (You can access the ith person's data in the following way. height (i),
weight(i), age (i)). Using the data, solve the following problems using the logical
indexing in Matlab. (30 pts)
height = [8.9 6.8 7.4 4.9 5.5 5.7 7.1 5.7 6.7 3.9 5.6 5.2 4.4 6.5
6.3 6.0 4.7 7.1 6.4 5.7];
weight = [144 133 128 201 183 156 125 133 146 166 123 103 121 157
158 159 147 154 140 167];
age = [60 25 33 37 54 27 56 25 53 45 59 56 65 65 37 55 30 22 57 45];
a) Calculate the mean values of age for someone whose height is greater than (>) 6.0,
AND weight is less than (<) 150.
b) Calculate the number of people whose height is greater than (>) 6.0, AND weight is
greater than (>) 150, AND age is less than (<) 50.