Question

In-Class Assignment 8 (15 pts) 1) [5 pts] Use a for loop to create a vector...

In-Class Assignment 8 (15 pts)

  1. 1) [5 pts] Use a for loop to create a vector of the squares of the numbers 1 through 5. Display the vector.

  2. 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. 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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.

Add a comment
Know the answer?
Add Answer to:
In-Class Assignment 8 (15 pts) 1) [5 pts] Use a for loop to create a vector...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT