Nested For Loop Statement: Write the following scripts using nested for loops (30 pts)
mat -
5 10 7 7 6
9 6 2 3 9
1 5 2 10 8
6 5 1 7 1
1 6 1 9 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: heighti, weighti, agei). Using the data, solve the following problems using the logical indexing in Matlab (30 pts):
6.3 6.0 4.7 7.1 6.4 5.7;
158 159 147 154 140 167;
age = [60 25 33 37 54 27 56 25 53 45 59 56 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 mean values of age for someone whose height is greater than 150 AND age is less than 50.