Question: 1. Pi Estimation, The value of Pie can be estimated from the expression: 2/Pi = root(2)/2 root(2 +root (2))/2 root(2 + root(2 + root(2)))/2 In

1. Pi Estimation, The value of Pie can be estimated from the expression: 2/Pi = root(2)/2 root(2 +root (2))/2 root(2 + root(2 + root(2)))/2 In a script file, write a MATLAB program that determine Pi for any number of terms. The program asks the user to enter the number of terms, and then calculates the corresponding value of Pi. Test your program with 5, 10, and 40 terms. Compare the result with pi. (Use format long)

2. Sorting Elements A vector is given by x = [4.5 5 16.12 21.8 10.1 10 16.11 5 14 3 3 2]. In a script file, using conditional statements and loops, write a program that rearranges the elements of x in order from the smallest to the largest. Do NOT use MATLAB built-in function sort.

3. Finding n In a script file, write a MATLAB program that finds a positive integer n such that the sum of all the integers 1 + 2 + 3 + + n is a number between 100 and 1000 whose three digits are identical. As output, the program displays the integer n and the corresponding sum.

4. Finding Primes In a function file named findPrimes.m, write a user-defined function named findPrimes that finds all the prime numbers between two numbers m and n. Name the function pr = findPrimes(m, n), where the input arguments m and n are positive integers and the output argument pr is a vector with the prime numbers. If m > n is entered when the function is called, the error message The value of n must be larger than the value of m. is displayed. If a negative number of a number that is not an integer is entered when the function is called, the error message The input argument must be a positive integer. is displayed. Do NOT use MATLAB built-in function primes and isprime.

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!