Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started