Question: EXERCISE 3 The counter in a for or while loop can have an explicit increment: for i=m:k:n. This advances the counter i by increment k

 EXERCISE 3 The counter in a for or while loop can

EXERCISE 3 The counter in a for or while loop can have an explicit increment: for i=m:k:n. This advances the counter i by increment k each time. In this problem we will evaluate the product of the first 7 odd numbers 1.3.5. .... 13 in two ways: (a) Write a script file that evaluates the product of the first 7 odd numbers using a for loop. (b) Evaluate the product of the first 7 odd numbers using a single MATLAB command. Use the MATLAB command prod. while loop The while loop repeats a sequence of commands as long as some condition is met. The basic structure of a while loop is the following: while end Here are some examples: Determine the sum of the inverses of squares of integers from 1 until the inverse of the integer square becomes less than 10-10: + +...+ while > 10-10. S = 0; % initialize running sum k = 1; % initialize current integer incr = 1; % initialize test value while incr>=1e-10 S = S+incr; k = k +1; incr = 1/k*2; end What is the value of S returned by this script? Compare to 1 2 R2 2 6 Create a row vector y that contains all the factorials below 2000: y = ( 1!, 2, 3, ...k! ] while k!

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!