2. The value of pi can be estimated by the following equation: = 12 n n=0...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. The value of pi can be estimated by the following equation: = 12 n n=0 (-1/3)" 2n+1 Write a MATLAB program that uses a loop to determine the value of the above expression. Have the program fun for values of n=10, n=100, n=1000, and n=10000. The value of expression at each n value should display. 3. The Sierpinski triangle can be made in MATLAB by plotting points iteratively according to one of the following three rules that are selected randomly with equal probability. Rule 1: xn+1 = 0.5xn Yn+1 = 0.5yn Rule 2: xn+10.5x + 0.25 3 Yn+1 = 0.5yn + 4 Rule 3: Xn+10.5x + 0.5 Yn+1 = 0.5yn Write a MATLAB program that calculates the x and y vectors and then plots y versus x as individual triangular points. Start with x=0 and y-0. Run the program four times with 10, 100, 1000, and 10,000 iterations and have each figure show. Format the plots properly. 4. Write a script file that creates an n x m matrix with elements that must have the following values. The value of each element in the first row is the number of the column and the value of each element in the first column Is the number of the row. The rest of the elements each have a value equal to the sum of the element above it and to the left of it. The program should ask the user to enter values for n and m. 5. The Taylor series expansion for cos(x) is: x 00 cos(x) = 1- +6 + + + 4! 6! n=0 (2n)! (-1)n -xn Where x is in radians. Write a MATLAB program that determines cos(x) using the Taylor series expansion. The program should ask the user to enter a value for an angle in degrees. Then the program should use a loop for adding the terms of the Taylor series. If an is the nth term in the series, then the sum Sn of the n terms is Sn-Sn-1+an, in each pass calculate the estimated error E given by E = |Sn-Sn-1]. Stop adding terms when E 0.000001. The program should display the value of cos(x) using 'fprintf'. The value of cos(x) is XXX.XX. 6. A list of 30 exam scores is give as: 64, 49, 59, 71, 99, 89, 82, 26, 69, 19, 61, 22, 87, 36, 98, 43, 23, 55, 90, 80, 76, 51, 73, 81, 88, 47, 5, 92, 70, 31. Write a MATLAB code that determines how many grades are between 0 and 19, between 20 and 39, between 40 and 59, between 60 and 79, and between 80 and 100. The results should be displayed, using 'fprintf, in the following form: Grades between 0 and 19: XXX Students Grades between 20 and 39: XXX Students 2. The value of pi can be estimated by the following equation: = 12 n n=0 (-1/3)" 2n+1 Write a MATLAB program that uses a loop to determine the value of the above expression. Have the program fun for values of n=10, n=100, n=1000, and n=10000. The value of expression at each n value should display. 3. The Sierpinski triangle can be made in MATLAB by plotting points iteratively according to one of the following three rules that are selected randomly with equal probability. Rule 1: xn+1 = 0.5xn Yn+1 = 0.5yn Rule 2: xn+10.5x + 0.25 3 Yn+1 = 0.5yn + 4 Rule 3: Xn+10.5x + 0.5 Yn+1 = 0.5yn Write a MATLAB program that calculates the x and y vectors and then plots y versus x as individual triangular points. Start with x=0 and y-0. Run the program four times with 10, 100, 1000, and 10,000 iterations and have each figure show. Format the plots properly. 4. Write a script file that creates an n x m matrix with elements that must have the following values. The value of each element in the first row is the number of the column and the value of each element in the first column Is the number of the row. The rest of the elements each have a value equal to the sum of the element above it and to the left of it. The program should ask the user to enter values for n and m. 5. The Taylor series expansion for cos(x) is: x 00 cos(x) = 1- +6 + + + 4! 6! n=0 (2n)! (-1)n -xn Where x is in radians. Write a MATLAB program that determines cos(x) using the Taylor series expansion. The program should ask the user to enter a value for an angle in degrees. Then the program should use a loop for adding the terms of the Taylor series. If an is the nth term in the series, then the sum Sn of the n terms is Sn-Sn-1+an, in each pass calculate the estimated error E given by E = |Sn-Sn-1]. Stop adding terms when E 0.000001. The program should display the value of cos(x) using 'fprintf'. The value of cos(x) is XXX.XX. 6. A list of 30 exam scores is give as: 64, 49, 59, 71, 99, 89, 82, 26, 69, 19, 61, 22, 87, 36, 98, 43, 23, 55, 90, 80, 76, 51, 73, 81, 88, 47, 5, 92, 70, 31. Write a MATLAB code that determines how many grades are between 0 and 19, between 20 and 39, between 40 and 59, between 60 and 79, and between 80 and 100. The results should be displayed, using 'fprintf, in the following form: Grades between 0 and 19: XXX Students Grades between 20 and 39: XXX Students
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
In terms of the inovice that has been received the recording clerk of AD should check for the price, terms and account details on the invoice against which document?
-
If you invested $320 million into a project today, and achieved operating cash flows of $180million, $60 million, $50 million, $50 million, and $40 million, how would you measure the following: a....
-
Evans Company had total sales of $3,000,000 for fiscal 2013. The costs of quality-related activities are given below. Returns/allowances .......................... $150,000 Design changes...
-
Write an application that displays every perfect number from 1 through 1,000. A perfect number is one that equals the sum of all the numbers that divide evenly into it. For example, 6 is perfect...
-
The following data are for Marvin Department Store. The account balances (in thousands) are for 2017. 1. Compute (a) the cost of goods purchased and (b) the cost of goods sold. 2. Prepare the income...
-
The bookkeeper for Lowells Country Music Bar left this incomplete balance sheet. Lowells working capital is $90,000 and its debt to assets ratio is 40 percent. Required Complete the balance sheet by...
-
Question 2 (50 points) When does the complex exponential prefactor for the solutions to the time- independent Schrodinger's equation matter? Let's find out with this example. An electron is confined...
-
You are an agent at a secret intelligence service. You are tasked with positioning spy satellites in orbit to spy on unsuspecting governments or people to collect data. You are tasked with...
-
What is an international new venture? Explain why it might be to the benefit of an entrepreneurial start-up to position itself as an international new venture from the outset.
-
Describe the two potential pitfalls of using a team to start a firm.
-
A potential candidate in the third borough conducted a poll to decide whether he should challenge the incumbent. From a previous poll, he knows that the current incumbent has the support of 45% of...
-
Why did WebHouses business model fail?
-
Describe the difference between a heterogeneous and a homogeneous founding team.
-
Fingen's 18-year, $1,000 par value bonds pay 9 percent interest annually. The market price of the bonds is $1,080 and the market's required yield to maturity on a comparable-risk bond is 10 percent....
-
When you weigh yourself on good old terra firma (solid ground), your weight is 142 lb. In an elevator your apparent weight is 121 lb. What are the direction and magnitude of the elevator's...
-
Write a user-defined function that plots an ellipse with axes that are parallel to the x and y axes, given the coordinates of its center and the length of the axes. For the function name and...
-
The Taylor series for cos(x) is: x2/2! + x4/4! x6/6! + x8/8! x10/10! + Plot the figure on the right, which shows, for -2 Tvo mo Sa teme
-
The electric field E due to a charged circular disk at a point at a distance z along the axis of the disk is given by where is the charge density, o is the permittivity constant, o = 8.85 10-12...
-
Consider the dynamic system, a mass, spring and damper structure, shown in Figure 2.2. (a) Draw a free-body diagram for the dynamic system (b) Derive the Input-Output model of the dynamic system k...
-
Two connected cars with an applied input force \(u(t)\) and negligible rolling friction can be represented by a translational mechanical system as shown below. (a) Draw the free-body diagrams of this...
-
Consider an RLC circuit consisting of a resistor \((R)\), an inductor \((L)\), and a capacitor \((C)\), connected in series, as depicted in Figure 2.4. Derive the Input-Output model of the network....
Study smarter with the SolutionInn App