Question: Matlab: Use the built-in primes function to create a vector of all primes below the input N. Now use a for loop to multiply adjacent

Matlab:

Use the built-in primes function to create a vector of all primes below the input N. Now use a for loop to multiply adjacent values together and output this vector from your function.

For example, if N is 10, then your function will create a vector of all primes below 10 and multiply each adjacent value. In this example, the prime vector is equal to:

[2, 3, 5, 7]

Your calculation would be:

2*3 3*5 5*7

And your final output vector would be:

[6, 15, 35]

A. Write out, in comments, how you will loop through the primes vector.

B. Set up your function, naming it primes_loop.m.

C. Complete the function and test it in todays script using an N value of 15.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!