In-Class Assignment 8 (15 pts)
1) [5 pts] Use a for loop to create a vector of the squares of the numbers 1 through 5. Display the vector.
2) [5 pts] Use the primes function to create a list of all the primes below 15. Now use a for loop to multiply adjacent values together.
For example, the first four prime numbers are 2357
Your calculation would be 2*3 3*5 5*7
which gives
6 15 35
3) [5 pts] Find the maximum value of the following array using two nested for loops. You will need to use an if statement to check for the maximum. Check your answer with MATLAB built in function ‘max’.
A=[20 18 50 55
-3 15 -90 32
12 18 34 23]
Hint: Each element in an array is described by the row number and the column number. Use one for loop to go through rows and the other for loop to go through columns.
1)

The solution to the first question using a for loop the squares of the numbers from 1 to 5 is written.
2)


The solution to prime number problem is given above
3)


The maximum value of the matrix is given as 55.

The answer is verified using max function.

Download the image if not clear.
In-Class Assignment 8 (15 pts) 1) [5 pts] Use a for loop to create a vector...