Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

How is the funding cost computed for a CFD contract?

Answered: 1 week ago