1) Write a generic function to integrate y(x)dx with the following format function I integrator (x,...
Fantastic news! We've Found the answer you've been seeking!
Question:
![image text in transcribed](https://dsd5zvtm8ll6.cloudfront.net/questions/2024/02/65cf55fd0dc6e_1708176712581.jpg)
Transcribed Image Text:
1) Write a generic function to integrate y(x)dx with the following format function I integrator (x, y, method) where x is a vector and y is a matrix whose columns y(:,j) are vectors of the same length as x and contain equally spaced data points. The output I is a row vector whose elements are the integrals of each column of y with respect to x. In other words, the jth element of I is I(j) = * y(:,j)dx. method is the technique used, and should either be the string 'trap' for the trapezoidal rule or 'simp' for Simpson's 1/3 rule. If the method argument is missing in the integrator function call, the default method should be set to the trapezoidal rule (Hint: look up how to vary the number of input arguments in a function call). The integrator function should evaluate the number of intervals to integrate and should check that this number is even when Simpson's 1/3 is selected; if that's not the case, the function should stop and print an error message warning the user. The integrator function should contain 2 subfunctions (local functions), one to implement the trapezoidal rule and one to implement Simpson's 1/3 rule. No loop should be used (use vector operations only). Check your subfunctions with simple problems for which you know the answer. 1) Write a generic function to integrate y(x)dx with the following format function I integrator (x, y, method) where x is a vector and y is a matrix whose columns y(:,j) are vectors of the same length as x and contain equally spaced data points. The output I is a row vector whose elements are the integrals of each column of y with respect to x. In other words, the jth element of I is I(j) = * y(:,j)dx. method is the technique used, and should either be the string 'trap' for the trapezoidal rule or 'simp' for Simpson's 1/3 rule. If the method argument is missing in the integrator function call, the default method should be set to the trapezoidal rule (Hint: look up how to vary the number of input arguments in a function call). The integrator function should evaluate the number of intervals to integrate and should check that this number is even when Simpson's 1/3 is selected; if that's not the case, the function should stop and print an error message warning the user. The integrator function should contain 2 subfunctions (local functions), one to implement the trapezoidal rule and one to implement Simpson's 1/3 rule. No loop should be used (use vector operations only). Check your subfunctions with simple problems for which you know the answer.
Expert Answer:
Answer rating: 100% (QA)
Function file function Iintegratorxymethod nlengthx1 hxendx1 I0 formula I... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Given that the variable books is of type int and the variable length is of type double, what value will be associated with the variable given the following assignments? a. books = 250 * (4 / 5); b....
-
Portray in words what transforms you would have to make to your execution to some degree (a) to accomplish this and remark on the benefits and detriments of this thought.You are approached to compose...
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
A ball of mass 0.440 kg moving east( + x direction) with a speed of 3.30m/s collides head-on with a 0.220-kg ball at rest. If the collision is perfectly elastic, what will be the speed and direction...
-
1. If p = 3q3, is p a function of q? 2. If y2 = 9x, is y a function of x? 3. If R = 3(x + 4, is R a function of x? 4. What are the domain and range of the function y = (9 - x?
-
Suppose that the greasy food sector of the economy did not offer health insurance before the passage of the ACA, and greasy food workers were not interested in health insurance. (a) Draw and label an...
-
P18-3 Claims rankings and cash distribution upon liquidation Jun is being liquidated under Chapter 7 of the bankruptcy act. All of Juns assets have been converted into cash, and $400,000 cash is...
-
Last year, only four of 32 professional sports teams in a new league turned a nominal accounting profit. Betty purchased such a team this year. Her taxable loss was determined to be $ 950,000. Can...
-
Identifying alpha on an asset when using a single-factor model may be explained because: O A. the asset is mispriced. O B. a single-factor model does not capture all the variables impacting on the...
-
Innovation and physical capital are 2 of the 4 factors of production. Discuss some specific ways that 1 of the following laws increased the productivity of 1 or both of these factors of production:...
-
Steve Reese is a well-known interior designer in Fort Worth, Texas. He wants to start his own business and convinces Rob ODonnell, a local merchant, to contribute the capital to form a partnership....
-
One of the main purposes of evaluation research is: a. reexamining previously collected data. b. monitoring and improving programs. c. generating rich descriptions of individual perspectives. d....
-
10.13 Sweetlip Ltd and Warehou Ltd are two family-owned flax-producing companies in New Zealand. Sweetlip Ltd is owned by the Wood family and the Bradbury family owns Warehou Ltd. The Wood family has...
-
distribution that is skewed to the right instead of being normally distributed. Assume that we collect a random sample of annual incomes of 50 statistics students. Can the distribution of incomes in...
-
Swain Athletic Gear (SAG) operates six retail outlets in a large Midwest city. One is in the center of the city on Cornwall Street and the others are scattered around the perimeter of the city....
-
Heavy Metal Corporation is expected to generate the following free cash flows over the next five years. Year 2 3 4 5 FCF ($ million) 53.0 68.0 78.0 75.0 82.0 Thereafter, the free cash flows are...
-
In muscle tissue, the ratio of phosphorylase a to phosphorylase b determines the rate of conversion of glycogen to glucose 1phosphate. Classify how each event affects the rate of glycogen breakdown...
-
Let x and y be vectors in an inner product space. Show that if x y then the distance between x and y is (||x||2 + ||y||2)1/2
-
For n =0, 1,2, show that the Legendre polynomial Pn(x) satisfies the second-order equation (1 - x2)y" - 2xy' + n(n + l)y = 0
-
Show that the matrix will have complex eigen values if is not a multiple Ï. Give a geometric interpretation of this result. cos sin -sin cos
-
12. The City of Wilson receives a large piece of sculpture valued at $240,000 as a gift to be placed in front of the municipal building. Which of the following is true for reporting the gift on the...
-
9. If this landfill is judged to be a governmental fund, what liability will be reported at the end of the second year on fund-based financial statements? a. $-0-. b. $110,000. c. $190,000. d....
-
11. What amount of liability should the city recognize on fund-based financial statements at December 31, Year 1 ? Assume that all remaining vacations will be taken in July. a.It depends on whether...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App