Question: Script need to be written in MatLab Code. l. The value of can be approximated by: rn 6 Write a script which asks the user
l. The value of can be approximated by: rn 6 Write a script which asks the user to input the number of iterations (n), then computes the expression, using a for loop to compute the summation with the spcified number of iterations. The larger the number of iterations, the closer the result should be to x. Print out the value of n, and the result using fprintf with 8 digits after the decimal to see the improved precision a. b. When your script is working, replace the input statement with afor loop, with a loop index, n, which goes from 1,000 to 10,000 in increments of 1,000. You will now have a loop inside a loop. This outer loop will set n, and your previous code, containing a loop for the summation, will compute pi for that value of n. Don't forget this outer loop's end statement. The result should be a line printed for each computation using a different value of n, something like: n 1000, approx- 3.14063806 n 2000, approx-3.14111527 Do not leave an input statement in your script- it will not publish
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
